/**
 *  @author     ETSI / STF422_EETS
 *  @version    $URL:$
 *              $Id:$
 *  @desc       Fast service advertisement protocol (ISO 24102-5) test cases
 */
module ItsFsap_TestCases {
    
    // Libcommon
    import from LibCommon_Time {
        modulepar PX_TNOAC;
        function f_sleep
    };
    import from LibCommon_VerdictControl all;
    import from LibCommon_Sync all;
    
    // LibIts
    
    // LibItsCalm
    import from CALMiitsscu language "ASN.1:1997" all;
    import from CALMllsap language "ASN.1:1997" { 
        type 
            IN_UNITDATA_request 
    }; 
    import from CALMmsap language "ASN.1:1997" {
        type 
            CommandRef, 
            MF_Request 
    };
    import from CALMfsap language "ASN.1:1997" {
        type 
            SAM, CTX, 
            GCsamctx 
    };
    import from CALMfntp language "ASN.1:1997" {
        type 
            FNTPNPDU, 
            NFfntpCommRequest 
    };
    import from LibItsFntp_TypesAndValues {
        const c_portSam, c_portNon;
    };
    import from LibItsFntp_Templates {
        template 
            mdw_inUnitDataReq, mw_llServiceAddr, mw_linkId, 
            m_llServiceAddr, m_linkId 
    };
    import from LibItsFntp_Functions {
        function 
            f_oct2npdu, 
            f_getIutWlLocalCiid, f_getIutRemoteDestCiidBc 
    };
    import from LibItsMgt_TypesAndValues {
        const c_dniCiid 
    }; 
    import from LibItsMgt_Templates all; 
    import from LibItsMgt_Functions { 
        function 
            f_getNextCommandRef, f_getNextPduCounter, 
            f_getIutSourceItsScuId, f_getIutDestItsScuId, f_getIutMedType, f_getIutCiAccessClass, f_getIutCiClass 
    }; 
    import from LibItsFsap_TypesAndValues all;
    import from LibItsFsap_Templates all; 
    import from LibItsFsap_Functions all; 
    import from LibItsFsap_Pixits all; 
    import from LibItsFsap_Pics all; 
    import from LibItsCalm_Interface {
        type ItsCalm, FsapInd 
    };
    import from LibItsCalm_TestSystem {
        type ItsCalmSystem
    };
    
    // 9.1 Service provider
    group serviceProvider {
        
        // 9.1.1 Combined ITS-S host and ITS-S router
        group combinedITS_S_Host_ITS_S_Router {
            
            group validBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows the requested access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application including a required access technology and non-IP communications
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via the requested access technology with the requested repetition rate, not inviting for a reply
                 *              after expiry of samRetransmitTimer
                 *              and before expiry of samRetransmitTimer + samMaxJitter
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BV/01
                 */
                testcase TC_FSAP_SP_HR_BV_01() runs on ItsCalm system ItsCalmSystem { 
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SP_HR_BV_01: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    // Assume that 'Initial conditions' are achieved
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HR_BV_01: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGcScheduleWithAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithNoSession() 
                    );
                    log("*** TC_FSAP_SP_HR_BV_01: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    log("*** TC_FSAP_SP_HR_BV_01: INFO: Expected IN-SAP message: ",
                        mw_fsapInd_inSap( 
                            mw_fsapInSapPrimitiveReq( 
                                mdw_inUnitDataReq( 
                                    mw_linkId(
                                        (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                        f_getIutMedTypeIso21215LocalCiid()
                                    ), 
                                    mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         ))),
                        " ***");
                    tc_ac.start;
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            f_getIutMedTypeIso21215LocalCiid()
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SP_HR_BV_01: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HR_BV_01: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()), 
                                " ***");
                            log("*** TC_FSAP_SP_HR_BV_01: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HR_BV_01: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HR_BV_01: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HR_BV_01: FAIL: Unexpected SAM message ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HR_BV_01: FAIL: Unknown FSAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_01: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_01: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_deregServer();
                            log("*** TC_FSAP_SP_HR_BV_01: INCONC: Expected SAM message not received ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BV_01: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BV_01
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with no request of specific access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application requiring non-IP communications
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via a suited access technology selected by the CI selection manager with the requested repetition rate, not inviting for a reply
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BV/02
                 */
                testcase TC_FSAP_SP_HR_BV_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                   
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SP_HR_BV_02: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    // Assume that 'Initial conditions' are achieved
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HR_BV_02: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithNoSession()
                    ); 
                    log("*** TC_FSAP_SP_HR_BV_02: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    log("*** TC_FSAP_SP_HR_BV_02: DEBUG: expected template: ", 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid())
                                        ), 
                                        ?  
                    ))));
                    tc_ac.start;                    
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid())
                                        ), 
                                        mw_linkId(
                                            f_getIutRemoteDestCiidBc(), 
                                            ?)  
//                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherLocalCiid()))  
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_HR_BV_02: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HR_BV_02: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()), 
                                " ***");
                            log("*** TC_FSAP_SP_HR_BV_02: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HR_BV_02: WARNING: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HR_BV_02: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HR_BV_02: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HR_BV_02: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_02: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_02: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_deregServer();
                            log("*** TC_FSAP_SP_HR_BV_02: INCONC: Expected management message not received ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BV_02: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BV_02
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology, and without request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application requiring non-IP communications in the session phase, but no change of communication channel
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via a suited access technology selected by the CI selection manager with the requested repetition rate, inviting for a reply
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BV/03
                 */
                testcase TC_FSAP_SP_HR_BV_03() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SP_HR_BV_03: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    // Assume that 'Initial conditions' are achieved
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HR_BV_03: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithSession()
                    ); 
                    log("*** TC_FSAP_SP_HR_BV_03: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    log("*** TC_FSAP_SP_HR_BV_02: DEBUG: expected template: ", 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeOtherLocalCiid()) 
                    ))));
                    tc_ac.start;
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherLocalCiid())) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_HR_BV_03: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HR_BV_03: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()), 
                                " ***");
                            log("*** TC_FSAP_SP_HR_BV_03: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()  
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HR_BV_03: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HR_BV_03: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HR_BV_03: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HR_BV_03: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_03: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_03: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_HR_BV_03: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BV_03: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BV_03
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology, and with request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH AND PICS_FSAP_MULTIPLE_AL_TECHNOLOGIES
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application requiring non-IP communications, and 
                 * requiring change of communication channel in the session phase
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via a suited access technology selected by the CI selection manager with the requested repetition rate, inviting for a reply, requesting a change of channel
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BV/04
                 */
                testcase TC_FSAP_SP_HR_BV_04() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SP_HR_BV_04: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    /***
                     * ITS-S shall be configured in a such way that a message in sent on the cfPort (management) to change the providerPort' 
                     * Problem: The managment message is not defined yet (2012/09/16)
                     */
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    // Assume that 'Initial conditions' are achieved
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HR_BV_04: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithNoSessionAndChannelChange()
                    ); 
                    log("*** TC_FSAP_SP_HR_BV_04: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_HR_BV_04: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HR_BV_04: INFO: Expected SAM: ", 
                                mw_sam_channelList( 
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndChangeChannel(), 
                                    {
                                        mw_sessionChannel(
                                            f_getIutServicelistWithSessionAndChangeChannel()[0].sessionChannel 
                                        )
                                    }
                                ), 
                                " ***");
                            log("*** TC_FSAP_SP_HR_BV_04: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam_channelList(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndChangeChannel(), 
                                    {
                                        mw_sessionChannel(
                                            f_getIutServicelistWithSessionAndChangeChannel()[0].sessionChannel 
                                        )
                                    }
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HR_BV_04: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HR_BV_04: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HR_BV_04: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HR_BV_04: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_04: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HR_BV_04: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_HR_BV_04: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BV_04: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BV_04
                
                /**
                 * @desc    Finalization of SIP upon reception of CTX for non-IP session
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH AND PICS_SIP_W_CTX
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT sending out periodically SAMs for one ITS-S application with non-IP based sessions
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a CTX as proper reply to a SAM
                 *      }
                 *      then {
                 *          the IUT generates a GCctx message to notify of reception of CTX
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BV/05
                 */
                testcase TC_FSAP_SP_HR_BV_05() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SP_HR_BV_05: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH AND PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regServer(
                        f_getIutGcScheduleWithAccessTechAndNonIp(), 
//                        f_getIutGcScheduleWithAccessTechAndNonIp(), // For debug purpose: f_getIutGcScheduleLongTPeriodTimeWithAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithSession() 
                    ); 
                    // Check that the first SAM message was sent
                    tc_wait.start;
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            f_getIutMedTypeIso21215LocalCiid()
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SP_HR_BV_05: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HR_BV_05: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()), 
                                " ***");
                            log("*** TC_FSAP_SP_HR_BV_05: INFO: SAM: ", v_sam, " ***");
                            if (not match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { // preambule is done 
                                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                log("*** TC_FSAP_SP_HR_BV_05: INFO: Preamble: IUT was setup properly ***");
                            } else {
                                log("*** TC_FSAP_SP_HR_BV_05: FAIL: SAM message not received yet ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HR_BV_05: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            f_deregServer();
                            log("*** TC_FSAP_SP_HR_BV_05: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    
                    // Test Body
                    // Clause 'when'
                    f_sendCtx(
                        { portLong := c_portSam } , 
                        { portLong := c_portSam }, 
                        m_ctx_noip( 
                            f_getLocalClientId(),  // Same is expected in GcCTX
                            m_nonIpContext( 
                                v_sam.serviceList[0].serviceID, 
                                v_sam.serviceList[0].serviceData, 
                                v_sam.serviceList[0].serverPort  
                            )
                        )
                    );
                    log("*** TC_FSAP_SP_HR_BV_05: INFO: CTX registration request done ***");
                    // Clause 'then' 
                    log("*** TC_FSAP_SP_HR_BV_05: DEBUG: Expected GcCTX template: ", 
                        mw_fsapGcCtx( 
                            mdw_gCctx( 
                                f_getIutApplicationId(), 
                                f_getLocalClientId(),  // Same as in CTX
                                mdw_ctxServiceDataNonIp( 
                                    v_sam.serviceList[0].serviceID,
                                    ?,  
                                    v_sam.serviceList[0].serverPort 
                    ))));
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcCtx( 
                                mdw_gCctx( 
                                    f_getIutApplicationId(), 
                                    f_getLocalClientId(), // Same as in CTX
                                    mdw_ctxServiceDataNonIp( 
                                        v_sam.serviceList[0].serviceID,
                                        ?,  
                                        v_sam.serviceList[0].serverPort 
                         )))) {
                            tc_ac.stop;
                            // And check for a MF-SAP.MF-REQUESTD/CTXrxNot message sent to the Groupcast Manager entity to update the forwarding table
                            if (PICS_ITS_MGT_NOT) {
                                f_fsapAwaitCtxRxNot( 
                                    m_ctxRxNot( 
                                        m_llServiceAddr(
                                            m_linkId(
                                                f_getIutWlLocalCiid(), 
                                                f_getIutWlLocalCiid())), 
                                        mdw_ctx(f_getIutClientId())
                                    ) 
                                );
                            }
                            log("*** TC_FSAP_SP_HR_BV_05: PASS: GCctx notification sent as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                        [] utPort.receive(UtFsapEventInd:?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SP_HR_BV_05: FAIL: Unexpected GCctx message ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        [] tc_ac.timeout {
                            log("*** TC_FSAP_SP_HR_BV_05: INCONC: Expected management message not received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BV_05: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BV_05
                
            } // End of group validBehavior
            
            group invalidBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific but not available access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH AND PICS_FSAP_MULTIPLE_AL_TECHNOLOGIES
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT does not know the requested access technology,
                 *      the IUT knows another access technology suited for FSAP
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application for the purpose of message distribution
                 *      }
                 *      then {
                 *          the IUT does not send out periodically SAMs via the existent access technology
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BI/01
                 */
                testcase TC_FSAP_SP_HR_BI_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SP_HR_BI_01: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    fsapPort.clear;
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HR_BI_01: INFO: Preamble done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithUnknownAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithNoSession() 
                    ); 
                    log("*** TC_FSAP_SP_HR_BI_01: INFO: GCregServer registration request sent ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            log("*** TC_FSAP_SP_HR_BI_01: FAIL: No message was expected ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_noac.timeout {
                            log("*** TC_FSAP_SP_HR_BI_01: PASS: No message received as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BI_01: INFO: test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BI_01
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology which is not available, and without request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT does not know a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application offering a session phase
                 *      }
                 *      then {
                 *          the IUT does not send out periodically SAMs
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HR/BI/02
                 */
                testcase TC_FSAP_SP_HR_BI_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SP_HR_BI_02: ERROR: 'PICS_FSAP_ROLE_SP AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HR_BI_02: INFO: Preamble done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithUnknownAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithSession() 
                    ); 
                    log("*** TC_FSAP_SP_HR_BI_02: INFO: GCregServer registration request sent ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            log("*** TC_FSAP_SP_HR_BI_02: FAIL: No message was expected ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_noac.timeout {
                            log("*** TC_FSAP_SP_HR_BI_02: PASS: No message received as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HR_BI_02: INFO: test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SP_HR_BI_02
                
            } // End of group invalidBehavior
            
        } // End of group combinedITS_S_Host_ITS_S_Router
        
        // 9.1.2 ITS-S host only
        group its_S_HostOnly {
            
            group validBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific access technology available in an ITS-S router unit
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows about availability of the requested access technology in an ITS-S router
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application including a required access technology
                 *      }
                 *      then {
                 *          the IUT forwards this request to the proper ITS-S router ITS-SCU applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BV/01
                 */
                testcase TC_FSAP_SP_HO_BV_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_HO_BV_01: ERROR: 'PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HO_BV_01: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGcScheduleWithAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithNoSession() 
                    );
                    log("*** TC_FSAP_SP_HO_BV_01: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( // TODO Check the step 'apply IICP'
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            f_getIutMedTypeIso21215LocalCiid()
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SP_HO_BV_01: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HO_BV_01: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()), 
                                " ***");
                            log("*** TC_FSAP_SP_HO_BV_01: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HO_BV_01: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HO_BV_01: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HO_BV_01: FAIL: Unexpected SAM message ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HO_BV_01: FAIL: Unknown FSAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_01: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_01: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_HO_BV_01: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BV_01: INFO: Test body done ***");
                    
                    // Postamble
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BV_01
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with no request of specific access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows about availability of a suitable access technology in an ITS-S router
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application
                 *      }
                 *      then {
                 *          the IUT forwards this request to the proper ITS-S router ITS-SCU applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BV/02
                 */
                testcase TC_FSAP_SP_HO_BV_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                   
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_HO_BV_02: ERROR: 'PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    // Assume that 'Initial conditions' are achieved
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HO_BV_02: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithNoSession()
                    ); 
                    log("*** TC_FSAP_SP_HO_BV_02: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    log("*** TC_FSAP_SP_HO_BV_02: DEBUG: expected template: ", 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid())
                                        ), 
                                        ?  
                    ))));
                    tc_ac.start;                    
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid())
                                        ), 
                                        mw_linkId(
                                            f_getIutRemoteDestCiidBc(), 
                                            ?)  
//                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherLocalCiid()))  
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_HO_BV_02: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HO_BV_02: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()), 
                                " ***");
                            log("*** TC_FSAP_SP_HO_BV_02: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HO_BV_02: WARNING: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HO_BV_02: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HO_BV_02: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HO_BV_02: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_02: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_02: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_deregServer();
                            log("*** TC_FSAP_SP_HO_BV_02: INCONC: Expected management message not received ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BV_02: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BV_02
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology, and without request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows about availability of a suitable access technology in an ITS-S router
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application requiring non-IP communications in the session phase, but no change of communication channel
                 *      }
                 *      then {
                 *          the IUT forwards this request to the proper ITS-S router ITS-SCU applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BV/03
                 */
                testcase TC_FSAP_SP_HO_BV_03() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_HO_BV_03: ERROR: 'PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HO_BV_03: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithSession()
                    ); 
                    log("*** TC_FSAP_SP_HO_BV_03: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherLocalCiid())) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_HO_BV_03: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HO_BV_03: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()), 
                                " ***");
                            log("*** TC_FSAP_SP_HO_BV_03: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()  
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HO_BV_03: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HO_BV_03: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HO_BV_03: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HO_BV_03: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_03: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_03: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_HO_BV_03: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BV_03: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BV_03
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology, and with request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows about availability of a suitable access technology in an ITS-S router
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application requiring non-IP communications, and requiring change of communication channel in the session phase
                 *      }
                 *      then {
                 *          the IUT forwards this request to the proper ITS-S router ITS-SCU applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BV/04
                 */
                testcase TC_FSAP_SP_HO_BV_04() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_HO_BV_04: ERROR: 'PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HO_BV_04: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithNoSessionAndChannelChange()
                    ); 
                    log("*** TC_FSAP_SP_HO_BV_04: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_HO_BV_04: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HO_BV_04: INFO: Expected SAM: ", 
                                mw_sam_channelList( 
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndChangeChannel(), 
                                    {
                                        mw_sessionChannel(
                                            f_getIutServicelistWithSessionAndChangeChannel()[0].sessionChannel 
                                        )
                                    }
                                ), 
                                " ***");
                            log("*** TC_FSAP_SP_HO_BV_04: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam_channelList(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndChangeChannel(), 
                                    {
                                        mw_sessionChannel(
                                            f_getIutServicelistWithSessionAndChangeChannel()[0].sessionChannel 
                                        )
                                    }
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_HO_BV_04: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_HO_BV_04: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_HO_BV_04: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HO_BV_04: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_04: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_HO_BV_04: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_HO_BV_04: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BV_04: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BV_04
                
                /**
                 * @desc    Finalization of SIP upon reception of CTX for non-IP session
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT awaiting reception of CTX messages
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a CTX as proper reply to a SAM
                 *      }
                 *      then {
                 *          the IUT replies with the first session message (REQN or REQW) from the ITS-S application
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BV/05
                 */
                testcase TC_FSAP_SP_HO_BV_05() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SP_HO_BV_05: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regServer(
                        f_getIutGcScheduleWithAccessTechAndNonIp(), 
//                        f_getIutGcScheduleWithAccessTechAndNonIp(), // For debug purpose: f_getIutGcScheduleLongTPeriodTimeWithAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithSession() 
                    ); 
                    // Check that the first SAM message was sent
                    tc_wait.start;
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            f_getIutMedTypeIso21215LocalCiid()
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SP_HO_BV_05: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_HO_BV_05: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()), 
                                " ***");
                            log("*** TC_FSAP_SP_HO_BV_05: INFO: SAM: ", v_sam, " ***");
                            if (not match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { // preambule is done 
                                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                log("*** TC_FSAP_SP_HO_BV_05: INFO: Preamble: IUT was setup properly ***");
                            } else {
                                log("*** TC_FSAP_SP_HO_BV_05: FAIL: SAM message not received yet ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_HO_BV_05: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            f_deregServer();
                            log("*** TC_FSAP_SP_HO_BV_05: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    
                    // Test Body
                    // Clause 'when'
                    f_sendCtx(
                        { portLong := c_portSam } , 
                        { portLong := c_portSam }, 
                        m_ctx_noip( 
                            f_getLocalClientId(),  // Same is expected in GcCTX
                            m_nonIpContext( 
                                v_sam.serviceList[0].serviceID, 
                                v_sam.serviceList[0].serviceData, 
                                v_sam.serviceList[0].serverPort  
                            )
                        )
                    );
                    log("*** TC_FSAP_SP_HO_BV_05: INFO: CTX registration request done ***");
                    // Clause 'then' 
                    log("*** TC_FSAP_SP_HO_BV_05: DEBUG: Expected GcCTX template: ", 
                        mw_fsapGcCtx( 
                            mdw_gCctx( 
                                f_getIutApplicationId(), 
                                f_getLocalClientId(),  // Same as in CTX
                                mdw_ctxServiceDataNonIp( 
                                    v_sam.serviceList[0].serviceID,
                                    ?,  
                                    v_sam.serviceList[0].serverPort 
                    ))));
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcCtx( 
                                mdw_gCctx( 
                                    f_getIutApplicationId(), 
                                    f_getLocalClientId(), // Same as in CTX
                                    mdw_ctxServiceDataNonIp( 
                                        v_sam.serviceList[0].serviceID,
                                        ?,  
                                        v_sam.serviceList[0].serverPort 
                         )))) {
                            tc_ac.stop;
                            // And check for a MF-SAP.MF-REQUESTD/CTXrxNot message sent to the Groupcast Manager entity to update the forwarding table
                            if (PICS_ITS_MGT_NOT) {
                                f_fsapAwaitCtxRxNot( 
                                    m_ctxRxNot( 
                                        m_llServiceAddr(
                                            m_linkId(
                                                f_getIutWlLocalCiid(), 
                                                f_getIutWlLocalCiid())), 
                                        mdw_ctx(f_getIutClientId())
                                    ) 
                                );
                            }
                            log("*** TC_FSAP_SP_HO_BV_05: PASS: GCctx notification sent as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                        [] utPort.receive(UtFsapEventInd:?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SP_HO_BV_05: FAIL: Unexpected GCctx message ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        [] tc_ac.timeout {
                            log("*** TC_FSAP_SP_HO_BV_05: INCONC: Expected management message not received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BV_05: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BV_05
                
            } // End of group validBehavior
            
            group invalidBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific but not available access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT does not know about existence of the requested access technology,
                 *      the IUT knows about availability of a suitable access technology in an ITS-S router
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application for the purpose of message distribution
                 *      }
                 *      then {
                 *          the IUT dows not forward this request to the proper ITS-S router ITS-SCU applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BI/01
                 */
                testcase TC_FSAP_SP_HO_BI_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_HO_BI_01: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    fsapPort.clear;
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HO_BI_01: INFO: Preamble done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithUnknownAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithNoSession() 
                    ); 
                    log("*** TC_FSAP_SP_HO_BI_01: INFO: GCregServer registration request sent ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            log("*** TC_FSAP_SP_HO_BI_01: FAIL: No message was expected ***");
                        }
                        [] tc_noac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            log("*** TC_FSAP_SP_HO_BI_01: PASS: No message received as expected ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BI_01: INFO: test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BI_01
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology which is not available, and without request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT does not know about availability of a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request for an ITS-S application offering a session phase
                 *      }
                 *      then {
                 *          the IUT dows not forward this request to the proper ITS-S router ITS-SCU applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/HO/BI/02
                 */
                testcase TC_FSAP_SP_HO_BI_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_HO_BI_02: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_HO_BI_02: INFO: Preamble done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithUnknownAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithSession() 
                    ); 
                    log("*** TC_FSAP_SP_HO_BI_02: INFO: GCregServer registration request sent ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            log("*** TC_FSAP_SP_HO_BI_02: FAIL: No message was expected ***");
                        }
                        [] tc_noac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            log("*** TC_FSAP_SP_HO_BI_02: PASS: No message received as expected ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_HO_BI_02: INFO: test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_HO_BI_02
                
            } // End of group invalidBehavior
            
        } // End of group its_S_HostOnly
        
        // 9.1.3 ITS-S router only
        group its_S_RouterOnly {
            
            group validBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for SAM transmission,
                 *      the IUT knows the requested access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request via Inter-ITS-SCU communications for an ITS-S application including a required access technology and non-IP communications
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via the requested access technology with the requested repetition rate, not inviting for a reply
                 *      }
                 *  }
                 * </pre> 
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BV/01
                 */
                testcase TC_FSAP_SP_RO_BV_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_RO_BV_01: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_RO_BV_01: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGcScheduleWithAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithNoSession() 
                    );
                    log("*** TC_FSAP_SP_RO_BV_01: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    t_maxRetransTimer.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            f_getIutMedTypeIso21215LocalCiid()
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SP_RO_BV_01: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_RO_BV_01: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()), 
                                " ***");
                            log("*** TC_FSAP_SP_RO_BV_01: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_RO_BV_01: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_RO_BV_01: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_RO_BV_01: FAIL: Unexpected SAM message ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_RO_BV_01: FAIL: Unknown FSAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_01: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_01: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_RO_BV_01: INCONC: Expected message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BV_01: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BV_01
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with no request of specific access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request via Inter-ITS-SCU communications for an ITS-S application requiring non-IP communications
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via a suited access technology selected by the CI selection manager with the requested repetition rate, not inviting for a reply
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BV/02
                 */
                testcase TC_FSAP_SP_RO_BV_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_RO_BV_02: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_RO_BV_02: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithNoSession()
                    ); 
                    log("*** TC_FSAP_SP_RO_BV_02: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherLocalCiid())
                                        ), 
                                        mw_linkId(
                                            f_getIutRemoteDestCiidBc(), 
                                            ?)  
//                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherLocalCiid()))  
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_RO_BV_02: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_RO_BV_02: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()), 
                                " ***");
                            log("*** TC_FSAP_SP_RO_BV_02: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_RO_BV_02: WARNING: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_RO_BV_02: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_RO_BV_02: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_RO_BV_02: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_02: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_02: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_RO_BV_02: INCONC: Expected message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BV_02: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BV_02
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology, and without request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request via Inter-ITS-SCU communications for an ITS-S application requiring non-IP communications
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via a suited access technology selected by the CI selection manager with the requested repetition rate, inviting for a reply
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BV/03
                 */
                testcase TC_FSAP_SP_RO_BV_03() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_RO_BV_03: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_RO_BV_03: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithSession()
                    ); 
                    log("*** TC_FSAP_SP_RO_BV_03: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherLocalCiid())) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_RO_BV_03: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_RO_BV_03: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()), 
                                " ***");
                            log("*** TC_FSAP_SP_RO_BV_03: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()  
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_RO_BV_03: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_RO_BV_03: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_RO_BV_03: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_RO_BV_03: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_03: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_03: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_RO_BV_03: INCONC: Expected message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BV_03: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BV_03
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology, and with request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT knows a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request via Inter-ITS-SCU communications for an ITS-S application requiring non-IP communications, and requiring change of communication channel in the session phase
                 *      }
                 *      then {
                 *          the IUT periodically sends out SAM via a suited access technology selected by the CI selection manager with the requested repetition rate, inviting for a reply, requesting a change of channel
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BV/04
                 */
                testcase TC_FSAP_SP_RO_BV_04() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    timer t_minRetransTimer := f_getIutSamRetransmitTimer();
                    timer t_maxRetransTimer := f_getIutSamRetransmitTimer() + f_getIutSamMaxJitter();
                    var boolean v_firstMessageReceived := false;
                    var boolean v_samNotificationReceived := false;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_RO_BV_04: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_RO_BV_04: INFO: Preamble: IUT was setup properly ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithNonIp(),
                        f_getIutServiceDataRegWithNoSessionAndChannelChange()
                    ); 
                    log("*** TC_FSAP_SP_RO_BV_04: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid(), f_getIutMedTypeOtherRemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), (f_getIutMedTypeIso21215LocalCiid(), f_getIutMedTypeOtherRemoteCiid())) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
//                            log("*** TC_FSAP_SP_RO_BV_04: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_RO_BV_04: INFO: Expected SAM: ", 
                                mw_sam_channelList( 
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndChangeChannel(), 
                                    {
                                        mw_sessionChannel(
                                            f_getIutServicelistWithSessionAndChangeChannel()[0].sessionChannel 
                                        )
                                    }
                                ), 
                                " ***");
                            log("*** TC_FSAP_SP_RO_BV_04: INFO: SAM: ", v_sam, " ***");
                            if (match(
                                v_sam, 
                                mw_sam_channelList(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndChangeChannel(), 
                                    {
                                        mw_sessionChannel(
                                            f_getIutServicelistWithSessionAndChangeChannel()[0].sessionChannel 
                                        )
                                    }
                            ))) { 
                                if (v_firstMessageReceived == false) { // First message is reached, start timer now
                                    v_firstMessageReceived := true;
                                    t_maxRetransTimer.start;
                                    tc_ac.start;
                                    repeat;
                                } else {
                                    if (v_samNotificationReceived == false) {
                                        v_samNotificationReceived := true;
                                        t_minRetransTimer.start;
                                        t_maxRetransTimer.start;
                                        // After the SAM received, check the retransmission
                                        tc_ac.start;
                                        repeat;
                                    }
                                    if (t_minRetransTimer.running) {
                                        log("*** TC_FSAP_SP_RO_BV_04: FAIL: SAM not transmitted at prescribed periodicity (too early) ***");
                                        t_minRetransTimer.stop;
                                        t_maxRetransTimer.stop;
                                        f_deregServer();
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                                    } else {
                                        t_maxRetransTimer.stop;
                                        log("*** TC_FSAP_SP_RO_BV_04: PASS: SAM transmitted at prescribed periodicity ***");
                                        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                                    }
                                }
                            } else {
                                log("*** TC_FSAP_SP_RO_BV_04: FAIL: Unexpected SAM PDU ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_RO_BV_04: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] t_minRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_04: INFO: Ready for retransmission ***");
                            repeat;
                        }
                        [] t_maxRetransTimer.timeout {
                            log("*** TC_FSAP_SP_RO_BV_04: INCONC: SAM not transmitted at prescribed periodicity (too late) ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_RO_BV_04: INCONC: Expected message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BV_04: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer(); 
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BV_04
                
                /**
                 * @desc    Finalization of SIP upon reception of CTX for non-IP session
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT sending out periodically SAMs for one ITS-S application with non-IP based sessions
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a CTX as proper reply to a SAM
                 *      }
                 *      then {
                 *          the IUT forwards the notification of CTX reception to the proper ITS-S host applying Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BV/05
                 */
                testcase TC_FSAP_SP_RO_BV_05() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var SAM v_sam;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SP_RO_BV_05: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regServer(
                        f_getIutGcScheduleWithAccessTechAndNonIp(), 
//                        f_getIutGcScheduleWithAccessTechAndNonIp(), // For debug purpose: f_getIutGcScheduleLongTPeriodTimeWithAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithSession() 
                    ); 
                    // Check that the first SAM message was sent
                    tc_wait.start;
                    alt {
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, f_getIutMedTypeIso21215RemoteCiid()), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            f_getIutMedTypeIso21215LocalCiid()
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), f_getIutMedTypeIso21215LocalCiid()) 
                         )))) -> value v_fsapInd {
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SP_RO_BV_05: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2sam(v_fntpNpdu.body, c_tbDone, v_sam);
                            log(
                                "*** TC_FSAP_SP_RO_BV_05: INFO: Expected SAM: ", 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithSessionAndNoChangeChannel()), 
                                " ***");
                            log("*** TC_FSAP_SP_RO_BV_05: INFO: SAM: ", v_sam, " ***");
                            if (not match(
                                v_sam, 
                                mw_sam(     
                                    f_getIutClientId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange() 
                            ))) { // preambule is done 
                                f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                                log("*** TC_FSAP_SP_RO_BV_05: INFO: Preamble: IUT was setup properly ***");
                            } else {
                                log("*** TC_FSAP_SP_RO_BV_05: FAIL: SAM message not received yet ***");
                                f_deregServer();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                            }
                        }
                        [] fsapPort.receive(?) {
                            log("*** TC_FSAP_SP_RO_BV_05: FAIL: Unknown IN-SAP message received ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }                        
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            f_deregServer();
                            log("*** TC_FSAP_SP_RO_BV_05: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    
                    // Test Body
                    // Clause 'when'
                    f_sendCtx(
                        { portLong := c_portSam } , 
                        { portLong := c_portSam }, 
                        m_ctx_noip( 
                            f_getLocalClientId(),  // Same is expected in GcCTX
                            m_nonIpContext( 
                                v_sam.serviceList[0].serviceID, 
                                v_sam.serviceList[0].serviceData, 
                                v_sam.serviceList[0].serverPort  
                            )
                        )
                    );
                    log("*** TC_FSAP_SP_RO_BV_05: INFO: CTX registration request done ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcCtx( 
                                mdw_gCctx( 
                                    f_getIutApplicationId(), 
                                    f_getLocalClientId(), // Same as in CTX
                                    mdw_ctxServiceDataNonIp( 
                                        v_sam.serviceList[0].serviceID,
                                        ?,  
                                        v_sam.serviceList[0].serverPort 
                         )))) {
                            tc_ac.stop;
                            // And check for a MF-SAP.MF-REQUESTD/CTXrxNot message sent to the Groupcast Manager entity to update the forwarding table
                            if (PICS_ITS_MGT_NOT) {
                                f_fsapAwaitCtxRxNot( 
                                    m_ctxRxNot( 
                                        m_llServiceAddr(
                                            m_linkId(
                                                f_getIutWlLocalCiid(), 
                                                f_getIutWlLocalCiid())), 
                                        mdw_ctx(f_getIutClientId())
                                    ) 
                                );
                            }
                            log("*** TC_FSAP_SP_RO_BV_05: PASS: GCctx notification sent as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
                        }
                        [] utPort.receive(UtFsapEventInd:?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SP_RO_BV_05: FAIL: Unexpected GCctx message ***");
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SP_RO_BV_05: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BV_05: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BV_05
                
            } // End of group validBehavior
            
            group invalidBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific but not available access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT does not know the requested access technology,
                 *      the IUT knows another access technology suited for FSAP
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request via Inter-ITS-SCU communications for an ITS-S application for the purpose of message distribution
                 *      }
                 *      then {
                 *          the IUT does not send out periodically SAMs via the known access technology
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BI/01
                 */
                testcase TC_FSAP_SP_RO_BI_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_RO_BI_01: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                   // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    fsapPort.clear;
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_RO_BI_01: INFO: Preamble done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithUnknownAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithNoSession() 
                    ); 
                    log("*** TC_FSAP_SP_RO_BI_01: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            log("*** TC_FSAP_SP_RO_BI_01: FAIL: No message was expected ***");
                        }
                        [] tc_noac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            log("*** TC_FSAP_SP_RO_BI_01: PASS: No message received as expected ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BI_01: INFO: test body done ***");
                    
                    // Postamble
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BI_01
                
                /**
                 * @desc    Registration of ITS-S application with need for a session, with no request of specific access technology which is not available, and without request to change communication channel for session phase
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having not registered any ITS-S application for service announcement,
                 *      the IUT does not know a suitable access technology
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a GCregServer registration request via Inter-ITS-SCU communications for an ITS-S application offering a session phase
                 *      }
                 *      then {
                 *          the IUT does not send out periodically SAMs
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SP/RO/BI/02
                 */
                testcase TC_FSAP_SP_RO_BI_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SP and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SP_RO_BI_02: ERROR: 'PICS_FSAP_ROLE_SP AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
                    log("*** TC_FSAP_SP_RO_BI_02: INFO: Preamble done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_regServer(
                        f_getIutGCscheduleWithUnknownAccessTechAndNonIp(), 
                        f_getIutServiceDataRegWithSession() 
                    ); 
                    log("*** TC_FSAP_SP_RO_BI_02: INFO: GCregServer registration request done ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            f_deregServer();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            log("*** TC_FSAP_SP_RO_BI_02: FAIL: No message was expected ***");
                        }
                        [] tc_noac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            log("*** TC_FSAP_SP_RO_BI_02: PASS: No message received as expected ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SP_RO_BI_02: INFO: test body done ***");
                    
                    // Postamble
                    f_deregServer();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SP_RO_BI_02
                
            } // End of group invalidBehavior
            
        } // End of group its_S_RouterOnly
        
    } // End of group serviceProvider
    
    // 9.2 Service user
    group serviceUser {
        
        // 9.2.1 Combined ITS-S host and ITS-S router
        group combinedITS_S_Host_ITS_S_Router {
            
            group validBehavior {
                
                /**
                 * @desc    Registration of ITS-S application for message distribution only (no session phase) with request of specific access technology
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, 
                 *      and having properly registered any ITS-S application without a session 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT forwards the related message to the ITS-S application using GCsam
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HR/BV/01
                 */
                testcase TC_FSAP_SU_HR_BV_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SU_HR_BV_01: ERROR: 'PICS_FSAP_ROLE_SU AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(),  
                        m_gCregClientWithNoSessionAndNoCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_HR_BV_01: INFO: GCregClient registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithNoSessionAndNoChannelChange(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HR_BV_01: INFO: SAM messages sent periodically ***");
                    // Clause 'then'
                    log(
                        "*** TC_FSAP_SU_HR_BV_01: INFO: Expected GcSam: ", 
                        mw_fsapGcSam( 
                            mw_gcSam( 
                                f_getIutApplicationId(), 
                                f_getIutClientId(), 
                                mw_samDataServerciceWithAccessTechAndNonIp( 
                                    f_getIutServiceId(), 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serviceData, 
                                    f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serverPort,
                                    mw_sessionChannel(8) 
                                ),
                                mw_llServiceAddr(
                                    mw_linkId(f_getIutRemoteDestCiidBc(), ?)
                        ))), 
                        " ***");
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSam( 
                                mw_gcSam( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_samDataServerciceWithAccessTechAndNonIp( 
                                        f_getIutServiceId(), 
                                        f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serviceData, 
                                        f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serverPort,
                                        mw_sessionChannel(8) 
                                    ),
                                    mw_llServiceAddr(
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?)
                        )))) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_01: PASS: GCsam notification as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        }
                        [] utPort.receive(UtFsapEventInd:?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_01: FAIL: Unexpected GCsam primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            log("*** TC_FSAP_SU_HR_BV_01: INCONC: Expected FA.indication primitive not received ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_HR_BV_01: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SU_HR_BV_01
                
                /**
                 * @desc    Reception of SAM with need for a session, without request to change communication channel for session phase, with need to send CTX
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND PICS_ROLE_RH AND PIC_SIP_W_CTX AND PICS_FSAP_CHANGE_COMM_CHANNEL
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, and having properly registered any ITS-S application with session initialisation using CTX 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT forwards the related message to the ITS-S application using GCsamctx, with is acknowledged providing a port number for the session
                 *          the IUT sends the requested CTX containing the port number received in the acknowledgement
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HR/BV/02
                 */
                testcase TC_FSAP_SU_HR_BV_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var UtFsapEventInd v_utFsapEventInd;
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var CTX v_ctx;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and PICS_ROLE_RH and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SU_HR_BV_02: ERROR: 'PICS_FSAP_ROLE_SU AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(), 
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_HR_BV_02: INFO: GCregClient registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithSessionAndNoChangeChannel(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HR_BV_02: INFO: SAM messages sent ***");
                    // Clause 'then'
                    log(
                        "*** TC_FSAP_SU_HR_BV_02: INFO: Expected GcSamCtx: ", 
                        mw_fsapGcSamCtx( 
                            mw_gcSamCtx( 
                                f_getIutApplicationId(), 
                                f_getIutClientId(), 
                                mw_serviceInfo_nonipService( 
                                    f_getIutServiceId(), 
                                    f_getIutSessionPort() 
                                ), 
                                mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        )), 
                        " ***");
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSamCtx( 
                                mw_gcSamCtx( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_serviceInfo_nonipService( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort() 
                                    ), 
                                    mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        ))) -> value v_utFsapEventInd { // 1. The IUT forwards the related message to the ITS-S application using GCsamctx
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_02: INFO: GCsamctx notification as expected, acknowledged providing a port number ", v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.serviceInfo.info.nonipService.providerPort, " ***");
                            f_fsapGenerateFaPrimitiveWithoutConfirm( // 2. With is acknowledged providing a port number for the session
                                m_generateFaSapPrimitivesDown( 
                                    m_faSapPrimitivesDown_gcSamCtxConf( 
                                        m_gcSamCtxConf( 
                                            f_getIutApplicationId(), 
                                            v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.link, 
                                            f_getIutSessionPort() 
                                        ) 
                                    ) 
                                ) 
                            );
                            log("*** TC_FSAP_SU_HR_BV_02: INFO: Start waiting for CTX on fsap port now ***");
                            tc_ac.start;
                            repeat; 
                        }
                        [] utPort.receive(UtFsapEventInd:?) -> value v_utFsapEventInd { 
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_02: FAIL: Unexpected FA.indication primitive: ,", v_utFsapEventInd, " ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, ?), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            ? 
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?) 
                         )))) -> value v_fsapInd { // 3. The IUT sends the requested CTX
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SU_HR_BV_02: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2ctx(v_fntpNpdu.body, c_tbDone, v_ctx);
                            log(
                                "*** TC_FSAP_SU_HR_BV_02: INFO: Expected CTX: ", 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                )), 
                                " ***");
                            log("*** TC_FSAP_SU_HR_BV_02: INFO: CTX: ", v_ctx, " ***");
                            if (match(
                                v_ctx, 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                    )
                                ))) {  
                                log("*** TC_FSAP_SU_HR_BV_02: PASS: CTX notification as expected ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            } else {
                                log("*** TC_FSAP_SU_HR_BV_02: FAIL: Unexpected CTX notification ***");
                                f_deregClient(f_getIutApplicationId());
                                f_stopServiceProvider();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_02: FAIL: Unexpected IN-SAP primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            log("*** TC_FSAP_SU_HR_BV_02: INCONC: Expected management message not received ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_HR_BV_02: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SU_HR_BV_02
                
                /**
                 * @desc    Reception of SAM with need for a session, with request to change communication channel for session phase, with need to send CTX
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND PICS_ROLE_RH AND PICS_SIP_W_CTX AND PICS_FSAP_CHANGE_COMM_CHANNEL
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, and having properly registered any ITS-S application with session initialisation using CTX 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT forwards the related message to the ITS-S application using GCsamctx, with is acknowledged providing a port number for the session
                 *          the IUT sends the requested CTX in the new channel containing the port number received in the acknowledgement
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HR/BV/03
                 */
                testcase TC_FSAP_SU_HR_BV_03() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var UtFsapEventInd v_utFsapEventInd;
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var CTX v_ctx;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and PICS_ROLE_RH and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SU_HR_BV_03: ERROR: 'PICS_FSAP_ROLE_SU AND PICS_ROLE_RH AND PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutClientApplicationId(), 
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(), 
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_HR_BV_03: INFO: GCregClient registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithSessionAndChangeChannel(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HR_BV_03: INFO: SAM messages sent ***");
                    // Clause 'then'
                    log(
                        "*** TC_FSAP_SU_HR_BV_03: INFO: Expected GcSamCtx: ", 
                        mw_fsapGcSamCtx( 
                            mw_gcSamCtx( 
                                f_getIutApplicationId(), 
                                f_getLocalClientId(), 
                                mw_serviceInfo_nonipService( 
                                    f_getIutServiceId(), 
                                    f_getIutSessionPort() 
                                ), 
                                mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        )), 
                        " ***");
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSamCtx( 
                                mw_gcSamCtx( 
                                    f_getIutApplicationId(), 
                                    f_getIutServerId(), 
                                    mw_serviceInfo_nonipService( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort() 
                                    ), 
                                    mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        ))) -> value v_utFsapEventInd { // 1. The IUT forwards the related message to the ITS-S application using GCsamctx
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_03: INFO: GCsamctx notification as expected, acknowledged providing a port number ", v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.serviceInfo.info.nonipService.providerPort, " ***");
                            f_fsapGenerateFaPrimitiveWithoutConfirm( // 2. With is acknowledged providing a port number for the session
                                m_generateFaSapPrimitivesDown( 
                                    m_faSapPrimitivesDown_gcSamCtxConf( 
                                        m_gcSamCtxConf( 
                                            f_getIutApplicationId(), 
                                            v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.link, 
                                            f_getIutSessionPort() 
                                        ) 
                                    ) 
                                ) 
                            );
                            tc_ac.start;
                            repeat; 
                        }
                        [] utPort.receive(UtFsapEventInd:?) { 
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_03: FAIL: Unexpected FA.indication primitive ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, ?), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            ?
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?) 
                         )))) -> value v_fsapInd { // 3. The IUT sends the requested CTX
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SU_HR_BV_03: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2ctx(v_fntpNpdu.body, c_tbDone, v_ctx);
                            log(
                                "*** TC_FSAP_SU_HR_BV_03: INFO: Expected CTX: ", 
                                mdw_ctx_nonIpContext( 
                                    f_getLocalClientId(), 
                                    mw_nonIpContext( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort()
                                    )
                                ), 
                                " ***");
                            log("*** TC_FSAP_SU_HR_BV_03: INFO: CTX: ", v_ctx, " ***");
                            if (match(
                                v_ctx, 
                                mdw_ctx_nonIpContext( 
                                    f_getLocalClientId(), 
                                    mw_nonIpContext( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort()
                                    )
                                ))) {  
                                log("*** TC_FSAP_SU_HR_BV_03: PASS: CTX notification as expected ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            } else {
                                log("*** TC_FSAP_SU_HR_BV_03: FAIL: Unexpected CTX notification ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [PICS_FSAP_FNTP == false] fsapPort.receive( 
                            mw_fsapInd_nfSap( 
                                mw_fsapNfSapPrimitiveReq( 
                                    ?, // TODO To ne enhanced 
                                    ?, 
                                    ? 
                         ))) -> value v_fsapInd { // 3. The IUT sends the requested CTX
                            tc_ac.stop;
                            f_oct2ctx(v_fntpNpdu.body, c_tbDone, v_ctx);
                            log(
                                "*** TC_FSAP_SU_HR_BV_03: INFO: Expected CTX: ", 
                                 mdw_ctx_nonIpContext( 
                                    f_getLocalClientId(), 
                                    mw_nonIpContext( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort()
                                    )
                                ), 
                                " ***");
                            log("*** TC_FSAP_SU_HR_BV_03: INFO: CTX: ", v_ctx, " ***");
                            if (match(
                                v_ctx, 
                                mdw_ctx_nonIpContext( 
                                    f_getLocalClientId(), 
                                    mw_nonIpContext( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort()
                                    )
                                ))) {  
                                log("*** TC_FSAP_SU_HR_BV_03: PASS: CTX notification as expected ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            } else {
                                log("*** TC_FSAP_SU_HR_BV_03: FAIL: Unexpected CTX notification ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_03: FAIL: Unexpected IN-SAP primitive ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SU_HR_BV_03: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_HR_BV_03: INFO: Test body done ***");
                    
                    // Postamble
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SU_HR_BV_03
                
                /**
                 * @desc    Reception of SAM with need for a session, with request to change communication channel for session phase, with need to send CTX
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having registered ITS applications, but not the one offered in the SAM 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing an unwanted ITS-AID
                 *      }
                 *      then {
                 *          the IUT discards the SAM without further actions
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HR/BV/04
                 */
                testcase TC_FSAP_SU_HR_BV_04() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SU_HR_BV_04: ERROR: 'PICS_FSAP_ROLE_SU AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), // FIXME To be tested with Commsignia, applicationId shall be the same during all the transactions session
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(),
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_HR_BV_04: INFO: GCregClient registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithSessionAndChangeChannel(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HR_BV_04: INFO: SAM messages sent ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected on success
                    alt {
                       [] fsapPort.receive {
                            tc_noac.stop;
                            log("*** TC_FSAP_SU_HR_BV_04: FAIL: No message was expected ***");
                        }
                        [] tc_noac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                            log("*** TC_FSAP_SU_HR_BV_04: PASS: GCregClient registration request done ***");
                        }
                    } // End of 'alt' statement
                    
                    // Postamble
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SU_HR_BV_04
                
                /**
                 * @desc    Reception of SAM with need for a session, with request to change communication channel for session phase, with the requested channel being unknown
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND PICS_ROLE_RH
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, and having properly registered any ITS-S application
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID with a request to change to an unknown channel
                 *      }
                 *      then {
                 *          the IUT discards the SAM without further actions
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HR/BV/05
                 */
                testcase TC_FSAP_SU_HR_BV_05() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and PICS_ROLE_RH)) {
                        log("*** TC_FSAP_SU_HR_BV_05: ERROR: 'PICS_FSAP_ROLE_SU AND PICS_ROLE_RH' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf01Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), // FIXME To be tested with Commsignia, applicationId shall be the same during all the transactions session
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(),
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_HR_BV_05: INFO: GCregClient registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithUnknownServiceId(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HR_BV_05: INFO: SAM messages sent ***");
                    // Clause 'then'
                    tc_noac.start; // No message expected on success
                    alt {
                        [] fsapPort.receive {
                            tc_noac.stop;
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            log("*** TC_FSAP_SU_HR_BV_05: FAIL: No message was expected ***");
                        }
                        [] tc_noac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            log("*** TC_FSAP_SU_HR_BV_05: PASS: SAM message was discarded as expected ***");
                        }
                    } // End of 'alt' statement
                    
                    // Postamble
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf01Down();
                    
                } // End of testcase TC_FSAP_SU_HR_BV_05
               
            } // End of group validBehavior
            
            group invalidBehavior {
                
            } // End of group invalidBehavior
            
        } // End of group combinedITS_S_Host_ITS_S_Router
        
        // 9.2.2 ITS-S host only
        group its_S_HostOnly {
            
            group validBehavior {
                
                /**
                 * @desc    Reception of SAM with need for a session with need to send CTX
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX
                 * Config Id: CF02
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, 
                 *      and having properly registered any ITS-S application with session initialisation using CTX 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM from the ITS-S router via Inter-ITS-SCU communications containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT notifies reception of the SAM to the ITS-S application, which is acknowledged with a port number. 
                 *          the IUT sends the requested CTX to the ITS-S router applying Inter-ITS-SCU communications containing the port number received in the acknowledgement
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HO/BV/01
                 */
                testcase TC_FSAP_SU_HO_BV_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SU_HO_BV_01: ERROR: 'PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(),  
                        m_gCregClientWithNoSessionAndNoCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_timeout);
                    log("*** TC_FSAP_SU_HO_BV_01: INFO: GCregServer registration request done ***");
                     
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithNoSessionAndNoChannelChange(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HO_BV_01: INFO: SAM messages sent ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        // TODO the IUT sends the requested CTX to the ITS-S router applying Inter-ITS-SCU communications containing the port number received in the acknowledgement
                        [] utPort.receive( 
                            mw_fsapGcSam( 
                                mw_gcSam( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_samDataServerciceWithAccessTechAndNonIp( 
                                        f_getIutServiceId(), 
                                        f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serviceData, 
                                        f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serverPort,
                                        mw_sessionChannel(8) 
                                    ),
                                    mw_llServiceAddr(
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?)
                        )))) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HO_BV_01: PASS: GCsam notification as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        }
                        [] utPort.receive(UtFsapEventInd:?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HO_BV_01: FAIL: Unexpected GCsam primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SU_HO_BV_01: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_HO_BV_01: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SU_HO_BV_01
                
                /**
                 * @desc    Reception of SAM with need for a session with need to send CTX with need to change communication channel
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND (PICS_ROLE_HONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, 
                 *      and having properly registered any ITS-S application with session initialisation using CTX 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM from the ITS-S router via Inter-ITS-SCU communications containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT notifies reception of the SAM to the ITS-S application, which is acknowledged with a port number. 
                 *          the IUT sends the requested CTX to the ITS-S router applying Inter-ITS-SCU communications containing the port number received in the acknowledgement
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/HO/BV/02
                 */
                testcase TC_FSAP_SU_HO_BV_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var UtFsapEventInd v_utFsapEventInd;
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var CTX v_ctx;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SU_HO_BV_02: ERROR: 'PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(), 
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_HO_BV_02: INFO: GCregServer registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithSessionAndChangeChannel(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_HO_BV_02: INFO: SAM messages sent ***");
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSamCtx( 
                                mw_gcSamCtx( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_serviceInfo_nonipService( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort() 
                                    ), 
                                    mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        ))) -> value v_utFsapEventInd { // 1. The IUT forwards the related message to the ITS-S application using GCsamctx
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HO_BV_02: INFO: GCsamctx notification as expected, acknowledged providing a port number ", v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.serviceInfo.info.nonipService.providerPort, " ***");
                            f_fsapGenerateFaPrimitiveWithoutConfirm( // 2. With is acknowledged providing a port number for the session
                                m_generateFaSapPrimitivesDown( 
                                    m_faSapPrimitivesDown_gcSamCtxConf( 
                                        m_gcSamCtxConf( 
                                            f_getIutApplicationId(), 
                                            v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.link, 
                                            f_getIutSessionPort() 
                                        ) 
                                    ) 
                                ) 
                            );
                            log("*** TC_FSAP_SU_HO_BV_02: INFO: Start waiting for CTX on fsap port now ***");
                            tc_ac.start;
                            repeat; 
                        }
                        [] utPort.receive(UtFsapEventInd:?) -> value v_utFsapEventInd { 
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HO_BV_02: FAIL: Unexpected FA.indication primitive: ,", v_utFsapEventInd, " ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, ?), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            ? 
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?) 
                         )))) -> value v_fsapInd { // 3. The IUT sends the requested CTX
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SU_HO_BV_02: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2ctx(v_fntpNpdu.body, c_tbDone, v_ctx);
                            log(
                                "*** TC_FSAP_SU_HO_BV_02: INFO: Expected CTX: ", 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                )), 
                                " ***");
                            log("*** TC_FSAP_SU_HO_BV_02: INFO: CTX: ", v_ctx, " ***");
                            if (match(
                                v_ctx, 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                    )
                                ))) {  
                                log("*** TC_FSAP_SU_HO_BV_02: PASS: CTX notification as expected ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            } else {
                                log("*** TC_FSAP_SU_HO_BV_02: FAIL: Unexpected CTX notification ***");
                                f_deregClient(f_getIutApplicationId());
                                f_stopServiceProvider();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HO_BV_02: FAIL: Unexpected IN-SAP primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SU_HO_BV_02: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_HO_BV_02: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SU_HO_BV_02
                
            } // End of group validBehavior
            
            group invalidBehavior {
                
            } // End of group invalidBehavior
            
        } // End of group its_S_HostOnly
        
        // 9.2.3 ITS-S router only
        group its_S_RouterOnly {
            
            group validBehavior {
                
                /**
                 * @desc    Reception of SAM for message distribution only (no session phase)
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW))
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, 
                 *      and having properly registered any ITS-S application without a session 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT forwards the related message to the ITS-S application using GCsam via Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/RO/BV/01
                 */
                testcase TC_FSAP_SU_RO_BV_01() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)))) {
                        log("*** TC_FSAP_SU_RO_BV_01: ERROR: 'PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW))' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(),  
                        m_gCregClientWithNoSessionAndNoCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_RO_BV_01: INFO: GCregClient registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    log("*** TC_FSAP_SU_RO_BV_01: INFO: SAM messages sent ***");
                    f_startServiceProvider( 
                        f_getIutServicelistWithNoSessionAndNoChannelChange(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSam( 
                                mw_gcSam( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_samDataServerciceWithAccessTechAndNonIp( 
                                        f_getIutServiceId(), 
                                        f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serviceData, 
                                        f_getIutServicelistWithNoSessionAndNoChannelChange()[0].serverPort,
                                        mw_sessionChannel(8) 
                                    ),
                                    mw_llServiceAddr(
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?)
                        )))) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_01: PASS: GCsam notification as expected ***");
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                        }
                        [] utPort.receive(UtFsapEventInd:?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_HR_BV_01: FAIL: Unexpected GCsam primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SU_RO_BV_01: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_RO_BV_01: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SU_RO_BV_01
                
                /**
                 * @desc    Reception of SAM with need for a session with need to send CTX
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, 
                 *      and having properly registered any ITS-S application without a session 
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT forwards the related message to the ITS-S application using GCsam via Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/RO/BV/02
                 */
                testcase TC_FSAP_SU_RO_BV_02() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var UtFsapEventInd v_utFsapEventInd;
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var CTX v_ctx;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SU_RO_BV_02: ERROR: 'PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(), 
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_RO_BV_02: INFO: GCregServer registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithSessionAndNoChangeChannel(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_RO_BV_02: INFO: SAM messages sent ***");
                    
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSamCtx( 
                                mw_gcSamCtx( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_serviceInfo_nonipService( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort() 
                                    ), 
                                    mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        ))) -> value v_utFsapEventInd { // 1. The IUT forwards the related message to the ITS-S application using GCsamctx
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_RO_BV_02: INFO: GCsamctx notification as expected, acknowledged providing a port number ", v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.serviceInfo.info.nonipService.providerPort, " ***");
                            f_fsapGenerateFaPrimitiveWithoutConfirm( // 2. With is acknowledged providing a port number for the session
                                m_generateFaSapPrimitivesDown( 
                                    m_faSapPrimitivesDown_gcSamCtxConf( 
                                        m_gcSamCtxConf( 
                                            f_getIutApplicationId(), 
                                            v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.link, 
                                            f_getIutSessionPort() 
                                        ) 
                                    ) 
                                ) 
                            );
                            log("*** TC_FSAP_SU_RO_BV_02: INFO: Start waiting for CTX on fsap port now ***");
                            tc_ac.start;
                            repeat; 
                        }
                        [] utPort.receive(UtFsapEventInd:?) -> value v_utFsapEventInd { 
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_RO_BV_02: FAIL: Unexpected FA.indication primitive: ,", v_utFsapEventInd, " ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, ?), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            ? 
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?) 
                         )))) -> value v_fsapInd { // 3. The IUT sends the requested CTX
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SU_RO_BV_02: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2ctx(v_fntpNpdu.body, c_tbDone, v_ctx);
                            log(
                                "*** TC_FSAP_SU_RO_BV_02: INFO: Expected CTX: ", 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                )), 
                                " ***");
                            log("*** TC_FSAP_SU_RO_BV_02: INFO: CTX: ", v_ctx, " ***");
                            if (match(
                                v_ctx, 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                    )
                                ))) {  
                                log("*** TC_FSAP_SU_RO_BV_02: PASS: CTX notification as expected ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            } else {
                                log("*** TC_FSAP_SU_RO_BV_02: FAIL: Unexpected CTX notification ***");
                                f_deregClient(f_getIutApplicationId());
                                f_stopServiceProvider();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_RO_BV_02: FAIL: Unexpected IN-SAP primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SU_RO_BV_02: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_RO_BV_02: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SU_RO_BV_02
                
                /**
                 * @desc    Reception of SAM with need for a session with need to send CTX with need to change communication channel
                 * <pre>
                 * Pics Selection: PICS_FSAP_ROLE_SU AND (PICS_ROLE_RONLY OR (PICS_ROLE_RH AND PICS_ITS_S_INW)) AND PICS_SIP_W_CTX
                 * Config Id: CF01
                 * Initial conditions: 
                 *  with {
                 *      the IUT having received GCregClient, 
                 *      and having properly registered any ITS-S application with session initialisation using CTX
                 *  }
                 * Expected behaviour:
                 *  ensure that {
                 *      when { 
                 *          the IUT having received a SAM containing the expected ITS-AID
                 *      }
                 *      then {
                 *          the IUT forwards the related message to the ITS-S application using GCsamctx via Inter-ITS-SCU communications
                 *      }
                 *  }
                 * </pre>
                 * 
                 * @version 1.1.2
                 * @see     ETSI TS 102 797-2 v1.1.2 TP/FSAP/SU/RO/BV/03
                 */
                testcase TC_FSAP_SU_RO_BV_03() runs on ItsCalm system ItsCalmSystem {
                    // Local variables
                    var UtFsapEventInd v_utFsapEventInd;
                    var FNTPNPDU v_fntpNpdu;
                    var FsapInd v_fsapInd;
                    var CTX v_ctx;
                    
                    // Test control
                    if (not(PICS_FSAP_ROLE_SU and (PICS_ROLE_RONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX)) {
                        log("*** TC_FSAP_SU_RO_BV_03: ERROR: 'PICS_FSAP_ROLE_SU and (PICS_ROLE_HONLY or (PICS_ROLE_RH and PICS_ITS_S_INW)) and PICS_SIP_W_CTX' required for executing the TC ***");
                        stop;
                    }
                    
                    // Test component configuration
                    f_cf02Up();
                    
                    // Test adapter configuration
                    
                    // Preamble
                    // Clause 'Initial conditions'
                    f_regClient(
                        f_getIutApplicationId(), 
                        f_getIutServiceId(), 
                        m_gCregClientWithSessionAndCtx( 
                            f_getIutApplicationId(), 
                            f_getIutServiceId(), 
                            f_getContextData() 
                        )                    
                    );
                    f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success); 
                    log("*** TC_FSAP_SU_RO_BV_03: INFO: GCregServer registration request done ***");
                    
                    // Test Body
                    // Clause 'when'
                    f_startServiceProvider( 
                        f_getIutServicelistWithSessionAndChangeChannel(), 
                        { portLong := c_portSam }, 
                        { portLong := c_portSam } 
                    );
                    log("*** TC_FSAP_SU_RO_BV_03: INFO: SAM messages sent ***");
                    
                    // Clause 'then'
                    tc_ac.start;
                    alt { 
                        [] utPort.receive( 
                            mw_fsapGcSamCtx( 
                                mw_gcSamCtx( 
                                    f_getIutApplicationId(), 
                                    f_getIutClientId(), 
                                    mw_serviceInfo_nonipService( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort() 
                                    ), 
                                    mw_llServiceAddr(mw_linkId(f_getIutRemoteDestCiidBc(), ?))
                        ))) -> value v_utFsapEventInd { // 1. The IUT forwards the related message to the ITS-S application using GCsamctx
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_RO_BV_03: INFO: GCsamctx notification as expected, acknowledged providing a port number ", v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.serviceInfo.info.nonipService.providerPort, " ***");
                            f_fsapGenerateFaPrimitiveWithoutConfirm( // 2. With is acknowledged providing a port number for the session
                                m_generateFaSapPrimitivesDown( 
                                    m_faSapPrimitivesDown_gcSamCtxConf( 
                                        m_gcSamCtxConf( 
                                            f_getIutApplicationId(), 
                                            v_utFsapEventInd.faSapPrimitivesUp.servPrimitive.GCsamctx.link, 
                                            f_getIutSessionPort() 
                                        ) 
                                    ) 
                                ) 
                            );
                            log("*** TC_FSAP_SU_RO_BV_03: INFO: Start waiting for CTX on fsap port now ***");
                            tc_ac.start;
                            repeat; 
                        }
                        [] utPort.receive(UtFsapEventInd:?) -> value v_utFsapEventInd { 
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_RO_BV_03: FAIL: Unexpected FA.indication primitive: ,", v_utFsapEventInd, " ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [PICS_FSAP_FNTP == true] fsapPort.receive( 
                            mw_fsapInd_inSap( 
                                mw_fsapInSapPrimitiveReq( 
                                    mdw_inUnitDataReq( 
                                        mw_linkId(
                                            (c_dniCiid, ?), // See ISO 21218 Table 6 - Address parameters in e.g. IN-UNITDATA.request for CIs using 48-bit MAC addresses
                                            ? 
                                        ), 
                                        mw_linkId(f_getIutRemoteDestCiidBc(), ?) 
                         )))) -> value v_fsapInd { // 3. The IUT sends the requested CTX
                            tc_ac.stop;
                            f_oct2npdu(v_fsapInd.msgIn.msgIn_in.servPrimitive.IN_UNITDATA_request.data, c_tbDone, v_fntpNpdu);
                            log("*** TC_FSAP_SU_RO_BV_03: INFO: FNTPPDU: ", v_fntpNpdu, " ***");
                            f_oct2ctx(v_fntpNpdu.body, c_tbDone, v_ctx);
                            log(
                                "*** TC_FSAP_SU_RO_BV_03: INFO: Expected CTX: ", 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                )), 
                                " ***");
                            log("*** TC_FSAP_SU_RO_BV_03: INFO: CTX: ", v_ctx, " ***");
                            if (match(
                                v_ctx, 
                                mdw_ctx_nonIpContext( 
                                    f_getIutClientId(), 
                                    mw_nonIpContext_contextdata( 
                                        f_getIutServiceId(), 
                                        f_getIutSessionPort(), 
                                        f_getContextData() 
                                    )
                                ))) {  
                                log("*** TC_FSAP_SU_RO_BV_03: PASS: CTX notification as expected ***");
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success); 
                            } else {
                                log("*** TC_FSAP_SU_RO_BV_03: FAIL: Unexpected CTX notification ***");
                                f_deregClient(f_getIutApplicationId());
                                f_stopServiceProvider();
                                f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                            }
                        }
                        [] fsapPort.receive(?) {
                            tc_ac.stop;
                            log("*** TC_FSAP_SU_RO_BV_03: FAIL: Unexpected IN-SAP primitive ***");
                            f_deregClient(f_getIutApplicationId());
                            f_stopServiceProvider();
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error); 
                        }
                        [] tc_ac.timeout {
                            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
                            log("*** TC_FSAP_SU_RO_BV_03: INCONC: Expected management message not received ***");
                        }
                    } // End of 'alt' statement
                    log("*** TC_FSAP_SU_RO_BV_03: INFO: Test body done ***");
                    
                    // Postamble
                    f_deregClient(f_getIutApplicationId());
                    f_stopServiceProvider();
                    f_poDefault();
                    f_cf02Down();
                    
                } // End of testcase TC_FSAP_SU_RO_BV_03
                
            } // End of group validBehavior
            
            group invalidBehavior {
                
            } // End of group invalidBehavior
            
        } // End of group its_S_RouterOnly
        
    } // End of group serviceUser
    
} // End of module ItsFsap_TestCases