module TestCodec_GeoNetworking {
  
  // LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_DataStrings all;
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;
  
  // LibIts
  //    import from ITS_Container language "ASN.1:1997" all;
  //    import from CAM_PDU_Descriptions language "ASN.1:1997"all;
  //    import from DENM_PDU_Descriptions language "ASN.1:1997" all;
  
  // LibItsCommon
  import from LibItsCommon_TypesAndValues all;
  import from LibItsCommon_Templates all;
  
  // LibItsExternal
  import from LibItsExternal_TypesAndValues all;
  
  //    // LibItsCam
  //    import from LibItsCam_TypesAndValues all;
  //    import from LibItsCam_TestSystem all;
  //    import from LibItsCam_Templates {
  //    template m_camReq;
  //    group camTemplateFunctions
  //    };
  //    
  //    // LibItsDenm
  //    import from LibItsDenm_Templates all;
  //    import from LibItsDenm_TestSystem all;
  
  // LibItsSecurity
  import from LibItsSecurity_TypesAndValues all;
  import from LibItsSecurity_Templates all;
  import from LibItsSecurity_Functions all;
  import from LibItsSecurity_Pixits all;

  // LibItsBtp
  import from LibItsBtp_TypesAndValues all;
  import from LibItsBtp_Templates all;
  
  // LibItsGeoNetworking
  import from LibItsGeoNetworking_TypesAndValues all;
  import from LibItsGeoNetworking_Templates all;
  import from LibItsGeoNetworking_Functions all;
  import from LibItsGeoNetworking_TestSystem all;
  import from LibItsGeoNetworking_Pixits all;
  import from LibItsGeoNetworking_Pics all;
  import from LibItsGeoNetworking_EncdecDeclarations all;
  
  // TestCodec
  import from TestCodec_TestAndSystem all;
  
  group LibItsGeoNetworking_testCases {
    
    group LibItsGeoNetworking_DummyTemplates {
      
      /**
       * @desc    Dummy template for GN_Address 
       */
      template (value) GN_Address m_dummyGnAddrIut := {
      typeOfAddress := e_manual,
      stationType := e_roadSideUnit,
      stationCountryCode := 33,
      mid := 'a4fedecabeef'O
      }
      
      /**
       * @desc    Dummy template for long position vector
       */
      template (value) LongPosVector m_dummyLongPosVectorIut := {
      gnAddr := m_dummyGnAddrIut,
      timestamp_ := 123456,
      latitude := 4856,
      longitude := 675,
      pai := '1'B,
      speed := 55,
      heading := 9876
      }
      
      template (value) GN_Address m_dummyGnAddrNodeA := {
      typeOfAddress := e_manual,
      stationType := e_pedestrian,
      stationCountryCode := 49,
      mid := 'a4fdea5ea5ed'O
      }
      
      template (value) GN_Address m_dummyGnAddrNodeB := {
      typeOfAddress := e_manual,
      stationType := e_specialVehicle,
      stationCountryCode := 50,
      mid := 'a40102030405'O
      }
      
      template (value) GN_Address m_dummyGnAddrNodeC := {
      typeOfAddress := e_manual,
      stationType := e_moped,
      stationCountryCode := 42,
      mid := 'deadbabebeef'O
      }
      
      template (value) LongPosVector m_dummyLongPosVectorNodeA := {
      gnAddr := m_dummyGnAddrNodeA,
      timestamp_ := 875,
      latitude := 265,
      longitude := 789,
      pai := '0'B,
      speed := 80,
      heading := 548
      }
        
      template (value) LongPosVector m_dummyLongPosVectorNodeB := {
      gnAddr := m_dummyGnAddrNodeB,
      timestamp_ := 4585,
      latitude := 126,
      longitude := 123,
      pai := '0'B,
      speed := 45,
      heading := 125
      }
            
      template (value) LongPosVector m_dummyLongPosVectorNodeC := {
      gnAddr := m_dummyGnAddrNodeC,
      timestamp_ := 23644,
      latitude := 23754,
      longitude := 49645,
      pai := '0'B,
      speed := 110,
      heading := 23
      }
            
      template (value) ShortPosVector m_dummyShortPosVectorNodeC := {
      gnAddr := m_dummyGnAddrNodeC,
      timestamp_ := 23644,
      latitude := 23754,
      longitude := 49645
      }
            
      template (value) Area m_dummyArea1 := {
      geoAreaPosLatitude := 298376,
      geoAreaPosLongitude := 32745,
      distanceA := 1234,
      distanceB := 5678,
      angle := 9123
      }
        
      template (value) Area m_dummyArea2 := {
      geoAreaPosLatitude := 873548,
      geoAreaPosLongitude := 2837,
      distanceA := 8765,
      distanceB := 4321,
      angle := 4567
      }
        
      template (value) GeoBroadcastArea m_dummyGeoBroadcastArea1 := {
      geoBroadcastSubType := e_geoBroadcastRect,
      geoBroadcastArea := m_dummyArea1
      }
        
      template (value) GeoBroadcastArea m_dummyGeoBroadcastArea2 := {
      geoBroadcastSubType := e_geoBroadcastElip,
      geoBroadcastArea := m_dummyArea2
      }
        
      template (value) GeoAnycastArea m_dummyGeoAnycastArea1 := {
      geoAnycastSubType := e_geoAnycastCircle,
      geoAnycastArea := m_dummyArea1
      }
        
      template (value) GeoAnycastArea m_dummyGeoAnycastArea2 := {
      geoAnycastSubType := e_geoAnycastRect,
      geoAnycastArea := m_dummyArea2
      }

      /**
       * @desc    Send template for GeoNetworking SHB Packet
       * @param   p_sourceLongPosVec  Long position vector of source
       */
      template (value) GnNonSecuredPacket m_geoNwShbPacket_payload(
                                                                   in template (value) LongPosVector p_sourceLongPosVec,
                                                                   in template (value) GnRawPayload p_payload
                                                                   ) modifies m_geoNwShbPacket := {
      payload :=  p_payload
      }

      template (value) GnNonSecuredPacket m_geoNwBeaconPacket_payload(
                                                                      in template (value) LongPosVector p_sourceLongPosVec,
                                                                      in template (value) GnRawPayload p_payload
                                                                      ) modifies m_geoNwBeaconPacket := {
      payload := p_payload
      }
	    
      /**
       * @desc    Send template for GeoUnicast header
       * @param   p_sourceLongPosVec      Long position vector of source 
       * @param   p_destinationLongPosVec Long position vector of destination 
       * @param   p_senderLongPosVec      Long position vector of sender
       * @param   p_seqNumber         Sequence number of GeoUnicast packet
       */
      template (value) ExtendedHeader m_geoUnicastHeaderGeoNetworking(
                                                                      in template (value) LongPosVector p_sourceLongPosVec,
                                                                      in template (value) ShortPosVector p_dstPosVector,
                                                                      in template (value) UInt16 p_seqNumber
                                                                      ) := {
      geoUnicastHeader := {
        seqNumber := p_seqNumber,
        reserved := c_uInt8Zero,
        srcPosVector := p_sourceLongPosVec,
        dstPosVector := p_dstPosVector
      }
      }

      template (value) GeoNetworkingInd m_geoNwInd_withLinkLayerDestination(
                                                                            in template (value) GeoNetworkingPdu p_geoNwMsg,
                                                                            in template (value) MacAddress p_llDestinationAdress := 'FFFFFFFFFFFF'O,
                                                                            in template (value) Bit256 p_ssp := int2bit(0, 256),
                                                                            in template (value) UInt32 p_its_aid := 0
                                                                            ) := {
      msgIn := p_geoNwMsg,
      macDestinationAddress := p_llDestinationAdress,
      ssp := p_ssp,
      its_aid := p_its_aid
      }
      
      /**
       * @desc    Receive template for GeoNetworking SHB Packet
       * @param   p_sourceLongPosVec  Long position vector of source (Default: ?)
       * @param   p_hopLimit          Maximum number of hops (Default: ?)
       */
      template (present) GnNonSecuredPacket mw_geoNwShbPacket_nextHeader(
                                                                         in template (present) LongPosVector p_sourceLongPosVec := ?,
                                                                         in template (present) UInt8 p_hopLimit := ?,
                                                                         in template (present) NextHeader p_nextHeader := ?
                                                                         ) modifies mw_geoNwShbPacket := {
      commonHeader := mw_commonHeaderWithHopLimit(
                                                  p_nextHeader,
                                                  m_shbHeaderType,
                                                  p_hopLimit
                                                  ),
      extendedHeader := mw_shbHeader(p_sourceLongPosVec),
      payload := ?
      }
      
    } // End of group LibItsGeoNetworking_DummyTemplates
        
    group testGeoNetMessages {
            
      /**
       * @desc validate GeoNetworkingReq/Anycast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetReq_AnycastPacket() runs on TCType system TCType {
        var GeoNetworkingReq v_gnReq;
        var octetstring v_buffer := '01002B0A00308000000F0A0004D200008431A4FDEA5EA5ED0000036B00000109000003150050022400048D8800007FE904D2162E23A3000044454641554C545F5041594C4F4144FFFFFFFFFFFFA0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
       
      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwAnycastPacket(
                                                                                       m_dummyLongPosVectorNodeA, 
                                                                                       1234, 
                                                                                       m_dummyGeoAnycastArea1
                                                                                       )),
                                                       oct2int('A0A0A0A0'O)
                                                       ));
        TestGeoNetworkingReq(
                             v_gnReq, 
                             false);
      v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
        TestDecodeGeoNetworkingReq(
                                   v_gnReq, 
                                   v_buffer
                                   );
      }
            
      /**
       * @desc validate GeoNetworkingInd/Anycast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetInd_AnycastPacket() runs on TCType system TCType {
        var template (value) GeoNetworkingInd v_gnInd;
        var octetstring v_buffer := '01002B0A00308000000F0A0004D200008431A4FDEA5EA5ED0000036B00000109000003150050022400048D8800007FE904D2162E23A3000044454641554C545F5041594C4F4144FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000A0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnInd := valueof(m_geoNwInd_withLinkLayerDestination(
                                                             m_geoNwPdu(
                                                                        m_geoNwAnycastPacket(
                                                                                             m_dummyLongPosVectorNodeA, 
                                                                                             1234, 
                                                                                             m_dummyGeoAnycastArea1
                                                                                             )),
                                                             -,
                                                             -,
                                                             oct2int('A0A0A0A0'O)
                                                             ));
        TestGeoNetworkingInd(
                             v_gnInd, 
                             false);

      v_gnInd.msgIn.gnPacket.packet.commonHeader.plLength := 15;
        TestDecodeGeoNetworkingInd(
                                   mw_geoNwInd_withLinkLayerDestination(
                                                                        valueof(v_gnInd.msgIn),
                                                                        ?
                                                                        ), 
                                   v_buffer
                                   );
      }
            
      /**
       * @desc validate GeoNetworkingReq/Broadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetReq_BroadcastPacket() runs on TCType system TCType {
        var GeoNetworkingReq v_gnReq;
        var octetstring v_buffer := '01002B0A00418000000F0A000D800000A832A40102030405000011E90000007E0000007B002D007D00048D8800007FE904D2162E23A3000044454641554C545F5041594C4F4144FFFFFFFFFFFFA0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwBroadcastPacket(
                                                                                         m_dummyLongPosVectorNodeB, 
                                                                                         3456, 
                                                                                         m_dummyGeoBroadcastArea1
                                                                                         )),
                                                       oct2int('A0A0A0A0'O)
                                                       ));
        TestGeoNetworkingReq(
                             v_gnReq, 
                             false);
      v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
        TestDecodeGeoNetworkingReq(
                                   v_gnReq, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingInd/Broadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetInd_BroadcastPacket() runs on TCType system TCType {
        var GeoNetworkingInd v_gnInd;
        var octetstring v_buffer := '01002B0A00418000000F0A000D800000A832A40102030405000011E90000007E0000007B002D007D00048D8800007FE904D2162E23A3000044454641554C545F5041594C4F4144FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000A0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnInd := valueof(m_geoNwInd_withLinkLayerDestination(
                                                             m_geoNwPdu(
                                                                        m_geoNwBroadcastPacket(
                                                                                               m_dummyLongPosVectorNodeB, 
                                                                                               3456, 
                                                                                               m_dummyGeoBroadcastArea1
                                                                                               )),
                                                             -,
                                                             -,
                                                             oct2int('A0A0A0A0'O)
                                                             ));
        TestGeoNetworkingInd(
                             v_gnInd, 
                             false);
      v_gnInd.msgIn.gnPacket.packet.commonHeader.plLength := 15;
        TestDecodeGeoNetworkingInd(
                                   v_gnInd, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingInd/Broadcast SHB
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetInd_ShbPacket() runs on TCType system TCType {
        var GeoNetworkingInd v_gnInd;
        var octetstring v_buffer := '01002B0A0050800000300A00A832A40102030405000011E90000007E0000007B002D007D0000000007D1000001020000273F7C730059F34F8C4E2DB0661FFFFFFC2231129E48927FC1F48082788A800F53080FFFC4014004FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000A0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnInd := valueof(m_geoNwInd_withLinkLayerDestination(
                                                             m_geoNwPdu(
                                                                        m_geoNwShbPacket_payload(
                                                                                                 m_dummyLongPosVectorNodeB,
                                                                                                 '07D1000001020000273F7C730059F34F8C4E2DB0661FFFFFFC2231129E48927FC1F48082788A800F53080FFFC4014004'O
                                                                                                 )),
                                                             -,
                                                             -,
                                                             oct2int('A0A0A0A0'O)
                                                             ));
        TestGeoNetworkingInd(
                             v_gnInd, 
                             false);
      v_gnInd.msgIn.gnPacket.packet.commonHeader.plLength := 48;
        TestDecodeGeoNetworkingInd(
                                   v_gnInd, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingInd/Broadcast SHB
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetInd_ShbPacket_1() runs on TCType system TCType {
        var template GeoNetworkingInd v_gnInd;
        var octetstring v_buffer := '01004c0120500280013c0100140070b3d5791b487ea4bdac19f58e2c0623a93f03e909270000000007d1000001020000272fbdac4059f34ee58e2daf67e00000000033669e40927001f48083109a8003a8ff3fffb000000fdfbc47ebf18ce0004f0095c0382c6700063814d607f0633800dbc0a4703f8b19c006de052481fc18ce0036f029a40fe0c67001b78149207e0633800dbc06a30289b19c0045e0225819418ce0027f01a8c1300c670024380d8a09a263380225c00410031b19c0022dfdfa7f7658ce0022efde23f5d6c67000277ef51faeb63380013bf788fd7db19c0009dfbc47ebad8ce0004efde1bf5f8c67000277ef11faeb63380013bf7a8fd7db19c0009dfbc47ebb18ce0004efde23f5d6c67000277ef0dfafb63380013bf788fd75b19c0009dfbd47ebf18ce0004efde23f5d6c67000277ef11faeb63380013bf786fd7e319c0009dfbc47ebad8ce0004efdea3f5f6c67000277ef11faeb6338001305d35a164FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000A0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_btpB) {
          log("PX_GN_UPPER_LAYER shall be set to e_btpB");
          stop;
        }

        v_gnInd := mw_geoNwInd_withLinkLayerDestination(
                                                        mw_geoNwPdu(
                                                                    mw_geoNwShbPacket
                                                                    ),
                                                        c_llBroadcast
                                                        );

        
        TestDecodeGeoNetworkingInd(
                                   v_gnInd, 
                                   v_buffer
                                   );
      
      }
            
      /**
       * @desc validate GeoNetworkingReq/Unicast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetReq_UnicastPacket() runs on TCType system TCType {
        var GeoNetworkingReq v_gnReq;
        var octetstring v_buffer := '01002B0A00208000000F0A0010E100008C2ADEADBABEBEEF00005C5C00005CCA0000C1ED006E00178C2ADEADBABEBEEF00005C5C00005CCA0000C1ED44454641554C545F5041594C4F4144FFFFFFFFFFFFA0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwUnicastPacket(
                                                                                       m_dummyLongPosVectorNodeC,
                                                                                       m_dummyShortPosVectorNodeC,
                                                                                       4321									       )),
                                                       oct2int('A0A0A0A0'O)
                                                       ));
        TestGeoNetworkingReq(
                             v_gnReq, 
                             false);
      v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 15;
        TestDecodeGeoNetworkingReq(
                                   v_gnReq, 
                                   v_buffer
                                   );
      }
            
      /**
       * @desc validate GeoNetworkingInd/Unicast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetInd_UnicastPacket() runs on TCType system TCType {
        var GeoNetworkingInd v_gnInd;
        var octetstring v_buffer := '01002B0A00208000000F0A0010E100008C2ADEADBABEBEEF00005C5C00005CCA0000C1ED006E00178C2ADEADBABEBEEF00005C5C00005CCA0000C1ED44454641554C545F5041594C4F4144FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000A0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnInd := valueof(m_geoNwInd_withLinkLayerDestination(
                                                             m_geoNwPdu(
                                                                        m_geoNwUnicastPacket(
                                                                                             m_dummyLongPosVectorNodeC,
                                                                                             m_dummyShortPosVectorNodeC,
                                                                                             4321									       )),
                                                             -,
                                                             -,
                                                             oct2int('A0A0A0A0'O)
                                                             ));
        TestGeoNetworkingInd(
                             v_gnInd, 
                             false);
      v_gnInd.msgIn.gnPacket.packet.commonHeader.plLength := 15;
        TestDecodeGeoNetworkingInd(
                                   v_gnInd, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingReq/Beacon
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetReq_BeaconPacket() runs on TCType system TCType {
        var GeoNetworkingReq v_gnReq;
        var octetstring v_buffer := '01002B0A0010800000040100A832A40102030405000011E90000007E0000007B002D007D464B1442FFFFFFFFFFFF00000000'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwBeaconPacket_payload(
                                                                                              m_dummyLongPosVectorNodeB,
                                                                                              '464b1442'O	    
                                                                                              ))));
        TestGeoNetworkingReq(
                             v_gnReq, 
                             false);
      v_gnReq.msgOut.gnPacket.packet.commonHeader.plLength := 4;
        TestDecodeGeoNetworkingReq(
                                   v_gnReq, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingInd/Beacon
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetInd_BeaconPacket() runs on TCType system TCType {
        var GeoNetworkingInd v_gnInd;
        var octetstring v_buffer := '01002B0A0010800000040100A832A40102030405000011E90000007E0000007B002D007D464B1442FFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000A0A0A0A0'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnInd := valueof(m_geoNwInd_withLinkLayerDestination(
                                                             m_geoNwPdu(
                                                                        m_geoNwBeaconPacket_payload(
                                                                                                    m_dummyLongPosVectorNodeB,
                                                                                                    '464b1442'O	    
                                                                                                    )),
                                                             -,
                                                             -,
                                                             oct2int('A0A0A0A0'O)
                                                             ));
        TestGeoNetworkingInd(
                             v_gnInd, 
                             false);
      v_gnInd.msgIn.gnPacket.packet.commonHeader.plLength := 4;
        TestDecodeGeoNetworkingInd(
                                   v_gnInd, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingReq/LsRequest
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetReq_LsRequestPacket() runs on TCType system TCType {
        var GeoNetworkingReq v_gnReq;
        var octetstring v_buffer := '01002B0A0060800000000A0030390000BC21A4FEDECABEEF0001E240000012F8000002A380372694BC21A4FEDECABEEFFFFFFFFFFFFF00000000'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnReq := valueof(
                         m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwLsRequestPacket(
                                                                                         m_dummyLongPosVectorIut,
                                                                                         12345,
                                                                                         m_dummyGnAddrIut
                                                                                         ))));
        TestGeoNetworkingReq(
                             v_gnReq, 
                             false);
      v_gnReq.msgOut.gnPacket.packet.payload := omit;
        TestDecodeGeoNetworkingReq(
                                   v_gnReq, 
                                   v_buffer
                                   );
                
      }
            
      /**
       * @desc validate GeoNetworkingReq/LsReply
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNetReq_LsReplyPacket() runs on TCType system TCType {
        var GeoNetworkingReq v_gnReq;
        var octetstring v_buffer := '01002B0A0061800000000A0030390000BC21A4FEDECABEEF0001E240000012F8000002A3803726948431A4FDEA5EA5ED0000036B0000010900000315FFFFFFFFFFFF00000000'O; // Check for 'LibItsGeoNetworking_TypesAndValues.encode:' output in codec traces to get the dump
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
      v_gnReq := valueof(
                         m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwLsReplyPacket(
                                                                                       m_dummyLongPosVectorIut,
                                                                                       f_longPosVector2ShortPosVector(valueof(m_dummyLongPosVectorNodeA)),
                                                                                       12345										 ))));
        TestGeoNetworkingReq(
                             v_gnReq, 
                             false);
      v_gnReq.msgOut.gnPacket.packet.payload := omit;
        TestDecodeGeoNetworkingReq(
                                   v_gnReq, 
                                   v_buffer
                                   );
                
      }
      
    } // End of group testGeoNetMessages

    group testGeoNetAcTester {

    } // End of group testGeoNetAcTester

    group testGeoNetUpperTester {

      /**
       * @desc Validate template GeoNetworking/UtGnInitialize
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnInitialize() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnInitialize m_utGnInitialize := { '0809AABBCCDDEEFF'O };
        var bitstring v_expEncMsg := oct2bit('000809AABBCCDDEEFF'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnInitialize));
      v_encMsg := encvalue(m_utGnInitialize);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnInitialize
      
      /**
       * @desc Validate template GeoNetworking/UtGnChangePosition
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnChangePosition() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnChangePosition m_utGnChangePosition := { 1234, 5678, 9876 };
        var bitstring v_expEncMsg := oct2bit('02000004D20000162E00002694'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnChangePosition));
      v_encMsg := encvalue(m_utGnChangePosition);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnChangePosition
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/GeoUnicast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_GeoUnicast_1() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateGeoUnicastMessage(f_getTsGnLocalAddress(c_compNodeB));
        var bitstring v_expEncMsg := oct2bit('50940000000000000B2710800000'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_GeoUnicast_1
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/GeoUnicast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_GeoUnicast_2() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateGeoUnicastMessageWithPayload(f_getTsGnLocalAddress(c_compNodeB), 'CAFEDECA'O);
        var bitstring v_expEncMsg := oct2bit('50940000000000000B2710800004CAFEDECA'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_GeoUnicast_2

      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/GeoBroadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_GeoBroadcast_1() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateGeoBroadcastMessage(valueof(GeoArea: {e_geoRect, m_dummyArea1 }));
        var bitstring v_expEncMsg := oct2bit('510127108000000000048D8800007FE904D2162E23A30000'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_GeoBroadcast_1
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/GeoBroadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_GeoBroadcast_2() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateGeoBroadcastMessageWithPayload(valueof(GeoArea: {e_geoElip, m_dummyArea2 }), 'CAFEDECA'O);
        var bitstring v_expEncMsg := oct2bit('5102271080000000000D544C00000B15223D10E111D70004CAFEDECA'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_GeoBroadcast_2

      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/GeoAnycast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_GeoAnycast_1() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateGeoAnycastMessage(valueof(GeoArea: {e_geoRect, m_dummyArea1 }));
        var bitstring v_expEncMsg := oct2bit('520127108000000000048D8800007FE904D2162E23A30000'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_GeoAnycast_1
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/GeoAnycast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_GeoAnycast_2() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateGeoAnycastMessageWithPayload(valueof(GeoArea: {e_geoElip, m_dummyArea2 }), 'CAFEDECA'O);
        var bitstring v_expEncMsg := oct2bit('5202271080000000000D544C00000B15223D10E111D70004CAFEDECA'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_GeoAnycast_2
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/Shb
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_Shb_1() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateShbMessage;
        var bitstring v_expEncMsg := oct2bit('53800000'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_Shb_1
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/Shb
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_Shb_2() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateShbMessageWithPayload('CAFEDECA'O);
        var bitstring v_expEncMsg := oct2bit('53800004CAFEDECA'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_Shb_2
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/Tsb
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_Tsb_1() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateTsbMessage;
        var bitstring v_expEncMsg := oct2bit('540A2710800000'O);
    
        // Encode template
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_Tsb_1
      
      /**
       * @desc Validate template GeoNetworking/UtGnTrigger/Tsb
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_UtGnTrigger_Tsb_2() runs on TCType system TCType {
        var bitstring v_encMsg;
        var UtGnInitialize v_decMsg;
        var integer v_res := 0;
        var template (value) UtGnTrigger m_utGnTrigger := m_generateTsbMessageWithLifetime(12345);
        var bitstring v_expEncMsg := oct2bit('540A3039800004CAFEDECA'O);
    
        // Encode template
      m_utGnTrigger.tsb.payload := 'CAFEDECA'O;
        log("Encode template ", valueof(m_utGnTrigger));
      v_encMsg := encvalue(m_utGnTrigger);
        log("Encoded message:  ", bit2oct(v_encMsg));
        // Check result
        if (not isbound(v_encMsg)) {
          setverdict(fail, "Encoding failed!");
          stop;
        }
        if (not match(v_encMsg, v_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(v_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
        setverdict(pass, "Encoding passed.");
      } // End of tc_GeoNet_UtGnTrigger_Tsb_2
      
    } // End of group testGeoNetUpperTester
    
    group testGeoNetPort {

      /**
       * @desc    Receive template for GeoNetworking DENM Packet
       * @param   p_destinationShortPosVec    Short position vector of destination
       * @param   p_seqNumber                 Sequence number of GeoUnicast packet
       * @param   p_nextHeader                Id of next header
       */
      template (present) GnNonSecuredPacket mw_geoNwTsbPacketWithNextHeader_cam(
                                                                                in template (present) LongPosVector p_sourceLongPosVec := ?,
                                                                                in template (present) UInt8 p_hopLimit := ?,
                                                                                in template (value) NextHeader p_nextHeader
                                                                                ) modifies mw_geoNwShbPacket := {
      commonHeader := mw_commonHeaderWithHopLimit(
                                                  p_nextHeader,
                                                  m_shbHeaderType,
                                                  p_hopLimit
                                                  ),
      payload := ?
      } // End of template mw_geoNwTsbPacketWithNextHeader_cam
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_1() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        var GeoNetworkingReq v_gnReq;
        var ExtendedHeader v_header;
        var boolean v_got_beacon := false;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          setverdict(inconc, "PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
        
        map(self:geoNetworkingPort, system:geoNetworkingPort);

      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast( // Not compliant with PX_GN_UPPER_LAYER, just for test
                                                       m_geoNwPdu(
                                                                  m_geoNwBroadcastPacket(
                                                                                         m_dummyLongPosVectorNodeB, 
                                                                                         3456, 
                                                                                         m_dummyGeoBroadcastArea1
                                                                                         ),
                                                                  Lifetime: {multiplier := c_defaultLifetime, ltBase := e_100s} // FIXME Looks like a TITAN bug!
                                                                  )));
        
        geoNetworkingPort.send(v_gnReq);
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBroadcastPacket
                                                               ))) {
            if (v_got_beacon == false) {
              v_got_beacon := true;
              setverdict(pass);
            }
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwLsRequestPacket(
                                                                                       ?,
                                                                                       ?
                                                                                       )))) -> value v_msg {
            log("Receive LsRequest: ", v_msg.msgIn);
            // Send LsReply
            f_sendGeoNetMessage(
                                valueof(m_geoNwReq_linkLayerBroadcast(
                                                                      m_geoNwPdu(
                                                                                 m_geoNwLsReplyPacket(
                                                                                                      m_dummyLongPosVectorNodeA,
                                                                                                      f_longPosVector2ShortPosVector(
                                                                                                                                     valueof(v_msg.msgIn.gnPacket.packet.extendedHeader.lsRequestHeader.srcPosVector)
                                                                                                                                     ),
                                                                                                      vc_localSeqNumber
                                                                                                      )))));
            if (v_got_beacon == false) {
              v_got_beacon := true;
            }
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   ?
                                                   )) -> value v_msg {
            log("Receive beacon: ", v_msg.msgIn);
            setverdict(fail);
          }
          [] tc_ac.timeout {
            if (v_got_beacon == false) {
              setverdict(inconc, "Expected message not received");
            }
          }
        }
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        
      } // End of testcase tc_GeoNet_Port_1
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_2() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        var AcGnResponse v_acGnResponse;
        var GeoNetworkingReq v_gnReq;
        var ExtendedHeader v_header;
        var boolean v_got_beacon := false; // Used with xxx_61_beacon pcap file
        var boolean v_got_shb := false; // Used with xxx_61_cam pcap file
        var LongPosVector v_longPosVectorIut;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          setverdict(inconc, "PX_GN_UPPER_LAYER shall be set to e_any when using xxx_61_beacon and xxx_61_cam");
          stop;
        }
        
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);
        
        // A small sleep to provide TA to read pcap file is it used
        tc_noac.start(5.0);
        alt {
          [] tc_noac.timeout {
          }
        } // end of 'alt' statement
        
        f_acTriggerEvent(m_getLongPosVector(f_getIutGnLocalAddress()));
        tc_ac.start;
        alt {
          [] acPort.receive(mw_getLongPosVectorAny(f_getIutGnLocalAddress())) -> value v_acGnResponse {
            tc_ac.stop;
            v_longPosVectorIut := v_acGnResponse.getLongPosVector;
            setverdict(pass);
          } 
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "GnAddress mismatch, check LibItsGeoNetworking_Pics.PICS_GN_LOCAL_GN_ADDR value in configuration file");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "timeout");
          }
        } // End of 'alt' statement

        f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader));

      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwBroadcastPacket(
                                                                                         m_dummyLongPosVectorNodeB, 
                                                                                         3456, 
                                                                                         m_dummyGeoBroadcastArea1
                                                                                         ),
                                                                  Lifetime: {multiplier := c_defaultLifetime, ltBase := e_100s} // FIXME Looks like a TITAN bug!
                                                                  )));
        geoNetworkingPort.send(v_gnReq);
        
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwLsRequestPacket(
                                                                                       ?,
                                                                                       ?
                                                                                       )))) -> value v_msg {
            log("Receive LsRequest: ", v_msg.msgIn);
            // Send LsReply
            f_sendGeoNetMessage(
                                valueof(m_geoNwReq_linkLayerBroadcast(
                                                                      m_geoNwPdu(
                                                                                 m_geoNwLsReplyPacket(
                                                                                                      m_dummyLongPosVectorNodeA,
                                                                                                      f_longPosVector2ShortPosVector(
                                                                                                                                     valueof(v_msg.msgIn.gnPacket.packet.extendedHeader.lsRequestHeader.srcPosVector)
                                                                                                                                     ),
                                                                                                      vc_localSeqNumber
                                                                                                      )))));
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwShbPacket_nextHeader(
                                                                                            -,
                                                                                            -,
                                                                                            e_btpA
                                                                                            )
                                                               )
                                                   )) -> value v_msg {
            log("Receive SHB packet: ", v_msg.msgIn);
            if (v_got_shb == false) {
              v_got_shb := true;
              setverdict(pass);
            }
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBeaconPacket
                                                               )
                                                   )) -> value v_msg {
            log("Receive beacon packet: ", v_msg.msgIn);
            if (v_got_beacon == false) {
              v_got_beacon := true;
              setverdict(pass);
            }
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   ?
                                                   )) -> value v_msg {
            log("Receive unexpected GeoNetworking message: ", v_msg.msgIn);
            setverdict(fail);
          }
          [] tc_ac.timeout {
            if ((v_got_beacon == false) and (v_got_shb == false)) {
              setverdict(inconc, "Expected messages not received");
            }
          }
        }

        f_acTriggerEvent(m_stopPassBeaconing);
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_Port_2
            
      /**
       * @desc validate beaconing with secured mode set in config file
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_3() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        
        if (PX_GN_UPPER_LAYER != e_any) {
          setverdict(inconc, "PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
        
        map(self:geoNetworkingPort, system:geoNetworkingPort);

        tc_ac.start;
        alt {
          [] tc_ac.timeout {
            setverdict(pass);
          }
        }
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        
      } // End of testcase tc_GeoNet_Port_3
      
      /**
       * @desc validate beaconing with secured mode set in config file
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_4() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        var AcGnResponse v_acGnResponse;
        var ExtendedHeader v_header;
        var LongPosVector v_longPosVectorIut;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          setverdict(inconc, "PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
        
        map(self:acPort, system:acPort);
        map(self:geoNetworkingPort, system:geoNetworkingPort);

        // A small sleep to provide TA to read pcap file is it used
        tc_noac.start(1.0);
        alt {
          [] tc_noac.timeout {
          }
        } // end of 'alt' statement
        
        f_acTriggerEvent(m_getLongPosVector(f_getIutGnLocalAddress()));
        tc_ac.start;
        alt {
          [] acPort.receive(mw_getLongPosVectorAny(f_getIutGnLocalAddress())) -> value v_acGnResponse {
            tc_ac.stop;
            v_longPosVectorIut := v_acGnResponse.getLongPosVector;
            setverdict(pass);
          } 
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "GnAddress mismatch, check LibItsGeoNetworking_Pics.PICS_GN_LOCAL_GN_ADDR value in configuration file");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "timeout");
          }
        } // End of 'alt' statement

        f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(v_longPosVectorIut).beaconHeader));
        
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(mw_geoNwInd(mw_geoNwSecPdu(mw_etsiTs103097Data_signed))) -> value v_msg {
            tc_ac.stop;
            log("v_msg = ", v_msg);
            setverdict(pass, "Security protocol version set to 3");
            f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
          }
          [] tc_ac.timeout {
            setverdict(pass);
          }
        }
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_Port_4
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_MultiPort() runs on ItsMtc system ItsGeoNetworkingSystem {
        var ItsGeoNetworking v_comp1;
        var ItsGeoNetworking v_comp2;

      v_comp1 := ItsGeoNetworking.create("Comp1") alive;
      v_comp2 := ItsGeoNetworking.create("Comp2") alive;
	
        connect(self:syncPort, mtc:syncPort);
        connect(v_comp1:syncPort, self:syncPort);
        connect(v_comp2:syncPort, self:syncPort);
        map(v_comp1:geoNetworkingPort, system:geoNetworkingPort);
        map(v_comp2:geoNetworkingPort, system:geoNetworkingPort);
	
        v_comp1.start(f_tc_GeoNet_MultiPort());
        v_comp2.start(f_tc_GeoNet_MultiPort());
        // Synchronization
        f_serverSyncNClientsAndStop(2, {c_prDone, c_tbDone});
	

        disconnect(self:syncPort, mtc:syncPort);
        disconnect(v_comp1:syncPort, self:syncPort);
        disconnect(v_comp2:syncPort, self:syncPort);
        unmap(v_comp1:geoNetworkingPort, system:geoNetworkingPort);
        unmap(v_comp2:geoNetworkingPort, system:geoNetworkingPort);
      }

      function f_tc_GeoNet_MultiPort() runs on ItsGeoNetworking {
        var GeoNetworkingReq v_gnReq;
        var ExtendedHeader v_header;
        var boolean v_got_it := false;
        var GeoNetworkingInd v_msg;
                
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);                
      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwBroadcastPacket(
                                                                                         m_dummyLongPosVectorNodeB, 
                                                                                         3456, 
                                                                                         m_dummyGeoBroadcastArea1
                                                                                         ))));
                
        //geoNetworkingPort.send(v_gnReq);
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwTsbPacketWithNextHeader_cam(
                                                                                                   -,
                                                                                                   -,
                                                                                                   e_btpB
                                                                                                   )))) {
            if (v_got_it == false) {
              v_got_it := true;
              tc_ac.stop;
              log("*** " & testcasename() & ": PASS: Message received ***");
              f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
            } else {
              repeat;
            }
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwLsRequestPacket(
                                                                                       ?,
                                                                                       ?
                                                                                       )))) -> value v_msg {
            log("Receive LsRequest: ", v_msg.msgIn);
            // Send LsReply
            f_sendGeoNetMessage(
                                valueof(m_geoNwReq_linkLayerBroadcast(
                                                                      m_geoNwPdu(
                                                                                 m_geoNwLsReplyPacket(
                                                                                                      m_dummyLongPosVectorNodeA,
                                                                                                      f_longPosVector2ShortPosVector(
                                                                                                                                     valueof(v_msg.msgIn.gnPacket.packet.extendedHeader.lsRequestHeader.srcPosVector)
                                                                                                                                     ),
                                                                                                      vc_localSeqNumber
                                                                                                      )))));
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBeaconPacket(?)
                                                               )
                                                   )) -> value v_msg {
            log("Receive beacon: ", v_msg.msgIn);
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   ?
                                                   )) -> value v_msg {
            tc_ac.stop;
            log("*** " & testcasename() & ": FAIL: Unexpected message received ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
          }
          [] tc_ac.timeout {
            if (v_got_it == false) {
              log("*** " & testcasename() & ": INCONC: Expected message not received ***");
              f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
            }
          }
        }
	
      } // End of function f_tc_GeoNet_MultiPort
        
      /**
       * @desc validate GeoNetworkingReq/Broadcast with UtPort
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_utPort() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        var GeoNetworkingReq v_gnReq;
        var ExtendedHeader v_header;
        var boolean v_got_it := false;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
        
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:utPort, system:utPort);

        f_utInitializeIut(m_gnInitialize);
        
      v_gnReq := valueof(m_geoNwReq_linkLayerBroadcast(
                                                       m_geoNwPdu(
                                                                  m_geoNwBroadcastPacket(
                                                                                         m_dummyLongPosVectorNodeB, 
                                                                                         3456, 
                                                                                         m_dummyGeoBroadcastArea1
                                                                                         ))));
        
        geoNetworkingPort.send(v_gnReq);
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwTsbPacketWithNextHeader_cam(
                                                                                                   -,
                                                                                                   -,
                                                                                                   e_btpB
                                                                                                   )))) {
            if (v_got_it == false) {
              v_got_it := true;
              setverdict(pass);
            }
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwLsRequestPacket(
                                                                                       ?,
                                                                                       ?
                                                                                       )))) -> value v_msg {
            log("Receive LsRequest: ", v_msg.msgIn);
            // Send LsReply
            f_sendGeoNetMessage(
                                valueof(m_geoNwReq_linkLayerBroadcast(
                                                                      m_geoNwPdu(
                                                                                 m_geoNwLsReplyPacket(
                                                                                                      m_dummyLongPosVectorNodeA,
                                                                                                      f_longPosVector2ShortPosVector(
                                                                                                                                     valueof(v_msg.msgIn.gnPacket.packet.extendedHeader.lsRequestHeader.srcPosVector)
                                                                                                                                     ),
                                                                                                      vc_localSeqNumber
                                                                                                      )))));
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBeaconPacket(?)
                                                               )
                                                   )) -> value v_msg {
            log("Receive beacon: ", v_msg.msgIn);
            repeat;
          }
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   ?
                                                   )) -> value v_msg {
            setverdict(fail);
          }
          [] tc_ac.timeout {
            if (v_got_it == false) {
              setverdict(inconc, "Expected message not received");
            }
          }
        }
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:utPort, system:utPort);
        
      } // End of testcase tc_GeoNet_utPort
      
      /**
       * @desc validate AcPort/getLongposVector
       * @verdict Pass on success, Fail otherwise
       * @remark Change system.geoNetworkingPort.params parameter in configuration file to use different vendor's beacon (4 vendor, >63 beacons)
       */
      testcase tc_GeoNet_acPort_getLongPositionVector_1() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var AcGnResponse v_result;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
        
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);

        // A small sleep to provide TA to read pcap file is it used
        tc_noac.start;
        alt {
          [] tc_noac.timeout {
          }
        } // end of 'alt' statement
        
        f_acTriggerEvent(m_getLongPosVector(f_getIutGnLocalAddress()));
        tc_ac.start;
        alt {
          [] acPort.receive(mw_getLongPosVectorAny(f_getIutGnLocalAddress())) -> value v_result {
            tc_ac.stop;
            log("v_result=", v_result);
            setverdict(pass);
          }
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "GnAddress mismatch, check LibItsGeoNetworking_Pics.PICS_GN_LOCAL_GN_ADDR value in configuration file");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "timeout");
          }
        } // End of 'alt' statement
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_getLongPositionVector_1
       
      /**
       * @desc validate AcPort/getLongposVector
       * @verdict Pass on success, Fail otherwise
       * @remark Change system.geoNetworkingPort.params parameter in configuration file to use different vendor's beacon (4 vendor, >63 beacons)
       */
      testcase tc_GeoNet_acPort_getLongPositionVector_2() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var AcGnResponse v_result;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
        
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);

        tc_ac.start;
        f_acTriggerEvent(m_getLongPosVector(PX_TS_NODE_A_LOCAL_GN_ADDR)); // Do nit use IUT GN Address
        alt {
          [] acPort.receive(AcGnResponse: { failure := { failure := true } }) {
            tc_ac.stop;
            setverdict(pass, "Received negative ack");
          }
          [] acPort.receive(mw_getLongPosVectorAny(f_getIutGnLocalAddress())) -> value v_result {
            tc_ac.stop;
            log("v_result=", v_result);
            setverdict(fail);
          }
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "GnAddress mismatch, check LibItsGeoNetworking_Pics.PICS_GN_LOCAL_GN_ADDR value in configuration file");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "timeout");
          }
        } // End of 'alt' statement
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_getLongPositionVector_2
       
      /**
       * @desc validate GeoNetworkingReq/Broadcast with AcPort/beaconing
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_acPort_beaconing_1() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var PositionTable v_positionTable := {};
        var GeoAreaTable v_areaTable := {};
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);

        f_preparePositionsAndAreas(v_positionTable, v_areaTable);
        f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);
        f_acTriggerEvent(m_startBeaconing(m_beaconHeader(f_getPosition(vc_componentName)).beaconHeader)); 
        tc_ac.start;
        alt {
          [] acPort.receive(AcGnResponse: { failure := { failure := true } }) {
            tc_ac.stop;
            setverdict(fail, "Received negative ack");
          }
          [] acPort.receive(AcGnResponse: { failure := { failure := false } }) {
            tc_ac.stop;
            setverdict(pass, "Received AC ACK");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Timeout while waiting for adapter control event result");
            stop;
          }
        } // End of 'alt' statement
                
        // A small sleep to send some beacons
        tc_noac.start;
        alt {
          [] geoNetworkingPort.receive(?) {
            repeat;
          }
          [] tc_noac.timeout {
            setverdict(pass, "Check that beaconing was started and stopped accordingly");
          }
        } // end of 'alt' statement
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_beaconing_1
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast with AcPort/beaconing
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_acPort_beaconing_2() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var PositionTable v_positionTable := {};
        var GeoAreaTable v_areaTable := {};
        var GeoNetworkingReq v_gnReq;
        var boolean v_got_it := false;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);

        f_preparePositionsAndAreas(v_positionTable, v_areaTable);    
        f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);
        
        f_acTriggerEvent(m_startBeaconing(m_beaconHeader(f_getPosition(vc_componentName)).beaconHeader)); 
        tc_ac.start;
        alt {
          [] acPort.receive(AcGnResponse: { failure := { failure := true } }) {
            tc_ac.stop;
            setverdict(fail, "Received negative ack");
          }
          [] acPort.receive(AcGnResponse: { failure := { failure := false } }) {
            tc_ac.stop;
            setverdict(pass, "Received AC ACK");
          }
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "Received unexpected AC message");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Timeout while waiting for adapter control event result");
          }
        } // End of 'alt' statement
                
        // A small sleep to send some beacons
        tc_noac.start;
        alt {
          [] geoNetworkingPort.receive(?) {
            repeat;
          }
          [] tc_noac.timeout {
            // Stop beaconing
            f_acTriggerEvent(m_stopBeaconing); 
          }
        } // end of 'alt' statement

        // Wait a little bit before terminate the test
        tc_noac.start;
        alt {
          [] tc_noac.timeout {
            setverdict(pass, "Check that beaconing was started and stopped accordingly");
          }
        } // end of 'alt' statement
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_beaconing_2
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast with AcPort/passing beacons
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_acPort_pass_beaconing_1() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var PositionTable v_positionTable := {};
        var GeoAreaTable v_areaTable := {};
        var GeoNetworkingReq v_gnReq;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);

        f_preparePositionsAndAreas(v_positionTable, v_areaTable);    
        f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);

        f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(f_getPosition(c_compIut)).beaconHeader));
        tc_ac.start;
        alt {
          [] acPort.receive(AcGnResponse: { failure := { failure := true } }) {
            tc_ac.stop;
            setverdict(fail, "Received negative ack");
          }
          [] acPort.receive(AcGnResponse: { failure := { failure := false } }) {
            tc_ac.stop;
            setverdict(pass, "Received AC ACK");
          }
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "Received unexpected AC message");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Timeout while waiting for adapter control event result");
          }
        } // End of 'alt' statement
                
        // A small sleep to send some beacons
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBeaconPacket(?)))) {
            tc_ac.stop;
            setverdict(pass);
          }
          [] geoNetworkingPort.receive {
            tc_ac.stop;
            setverdict(fail, "Unexpected message received");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Expected message not received");
          }
        } // end of 'alt' statement
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_pass_beaconing_1
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast with AcPort/passing beacons
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_acPort_pass_beaconing_2() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var PositionTable v_positionTable := {};
        var GeoAreaTable v_areaTable := {};
        var GeoNetworkingReq v_gnReq;
        var GeoNetworkingInd v_msg;
        
        if (PX_GN_UPPER_LAYER != e_any) {
          log("PX_GN_UPPER_LAYER shall be set to e_any");
          stop;
        }
                
        map(self:geoNetworkingPort, system:geoNetworkingPort);
        map(self:acPort, system:acPort);

        f_preparePositionsAndAreas(v_positionTable, v_areaTable);    
        f_initialiseComponent(v_positionTable, v_areaTable, c_compNodeB);

        f_acTriggerEvent(m_startPassBeaconing(m_beaconHeader(f_getPosition(c_compIut)).beaconHeader));
        tc_ac.start;
        alt {
          [] acPort.receive(AcGnResponse: { failure := { failure := true } }) {
            tc_ac.stop;
            setverdict(fail, "Received negative ack");
          }
          [] acPort.receive(AcGnResponse: { failure := { failure := false } }) {
            tc_ac.stop;
            setverdict(pass, "Received AC ACK");
          }
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "Received unexpected AC message");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Timeout while waiting for adapter control event result");
          }
        } // End of 'alt' statement
        
        // A small sleep to send some beacons
        tc_ac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBeaconPacket(?)))) {
            tc_ac.stop;
            setverdict(pass);
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Expected message not received");
          }
        } // end of 'alt' statement

        f_acTriggerEvent(m_stopPassBeaconing);
        tc_ac.start;
        alt {
          [] acPort.receive(AcGnResponse: { failure := { failure := true } }) {
            tc_ac.stop;
            setverdict(fail, "Received negative ack");
          }
          [] acPort.receive(AcGnResponse: { failure := { failure := false } }) {
            tc_ac.stop;
            setverdict(pass, "Received AC ACK");
          }
          [] acPort.receive {
            tc_ac.stop;
            setverdict(fail, "Received unexpected AC message");
          }
          [] tc_ac.timeout {
            setverdict(inconc, "Timeout while waiting for adapter control event result");
          }
        } // End of 'alt' statement
        
        // Check that no beacon are received now
        geoNetworkingPort.clear;
        tc_noac.start;
        alt {
          [] geoNetworkingPort.receive(
                                       mw_geoNwInd(
                                                   mw_geoNwPdu(
                                                               mw_geoNwBeaconPacket(?)))) {
            tc_noac.stop;
            setverdict(fail, "Should not receive beacon");
          }
          [] tc_noac.timeout {
            setverdict(pass);
          }
        } // end of 'alt' statement
        
        unmap(self:geoNetworkingPort, system:geoNetworkingPort);
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_pass_beaconing_2
      
      /**
       * @desc validate GeoNetworkingReq/Broadcast with AcPort/beaconing
       * @verdict Pass on success, Fail otherwise
       */
      testcase tc_GeoNet_Port_acPort_secured_1() runs on ItsGeoNetworking system ItsGeoNetworkingSystem {
        // Variables
        var GeoNetworkingInd v_msg;
        
        map(self:acPort, system:acPort);

        f_loadCertificates(PX_IUT_SEC_CONFIG_NAME);
        
        acPort.send(m_acEnableSecurity(cc_taCert_A)); 
        tc_ac.start;
        alt {
          [] acPort.receive(m_acSecResponseSuccess) {
            tc_ac.stop;
          }
          [] acPort.receive {
            tc_ac.stop;
            log("*** " & __SCOPE__ & ": ERROR: Received unexpected message ***");
            f_selfOrClientSyncAndVerdict("error", e_error);
          }
          [] tc_ac.timeout {
            log("*** " & __SCOPE__ & ": ERROR: Timeout while waiting for adapter control event result ***");
            f_selfOrClientSyncAndVerdict("error", e_timeout);
          }
        } // End of 'alt' statement
        
        unmap(self:acPort, system:acPort);
        
      } // End of testcase tc_GeoNet_acPort_secured_1
      
    } // End of group testGeoNetPort
    
  } // End of group LibItsGeoNetworking_testCases
    
  group encdec_functions {
        
    function TestGeoNetworkingReq(
                                  in template (value) GeoNetworkingReq p_geoNetworkingReq,
                                  in boolean p_decode := true, 
                                  in template (omit) bitstring p_expEncMsg := omit 
                                  ) runs on TCType {
      var bitstring v_encMsg;
      var template (omit) TestRecord v_tr := { bs := p_expEncMsg };
      var GeoNetworkingReq v_decMsg;
      var integer v_res := 0;
    
      // Encode template
      log("Encode template ", valueof(p_geoNetworkingReq));
    v_encMsg := encvalue(p_geoNetworkingReq);
      log("Encoded message:  ", bit2oct(v_encMsg));
      // Check result
      if (not isbound(v_encMsg)) {
        setverdict(fail, "Encoding failed!");
        stop;
      }
      if (ispresent(v_tr.bs)) {
        if (not match(v_encMsg, p_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(p_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
      }
      setverdict(pass, "Encoding passed.");
    
      // Check decoding
      if (p_decode == true) {
      v_res := decvalue(v_encMsg, v_decMsg);
        log("Decoded message: ", v_decMsg);
        select (v_res) {
        case (0) {
          if(match(v_decMsg, p_geoNetworkingReq)) {
            setverdict(pass);
          } else {
            setverdict(fail);
          }
        }
        case (1) {
          setverdict(fail, "Decoding failed.");
        }
        case (2) {
          setverdict(fail, "Not enough bits.");
        }
        }
      }
            
    } // End of function TestGeoNetworkingReq
        
    function TestDecodeGeoNetworkingReq(
                                        in template GeoNetworkingReq p_geoNetworkingReq, 
                                        in template (present) octetstring p_expEncMsg
                                        ) runs on TCType {
      var GeoNetworkingReq v_decMsg;
      var bitstring v_encMsg := oct2bit(valueof(p_expEncMsg));
      var integer v_res := 0;
    
    v_res := decvalue(v_encMsg, v_decMsg);
      select (v_res) {
      case (0) {
        log("v_decMsg          : ", v_decMsg);
        if(match(valueof(v_decMsg), p_geoNetworkingReq)) {
          setverdict(pass);
        } else {
          setverdict(fail);
        }
      }
      case (1) {
        setverdict(fail, "Decoding failed.");
      }
      case (2) {
        setverdict(fail, "Not enough bits.");
      }
      } // End of 'select' statement
            
    }// End of function TestDecodeGeoNetworkingReq
        
    function TestGeoNetworkingInd(
                                  in template (value) GeoNetworkingInd p_geoNetworkingInd,
                                  in boolean p_decode := true, 
                                  in template (omit) bitstring p_expEncMsg := omit 
                                  ) runs on TCType {
      var bitstring v_encMsg;
      var template (omit) TestRecord v_tr := { bs := p_expEncMsg };
      var GeoNetworkingInd v_decMsg;
      var integer v_res := 0;
    
      // Encode template
      log("Encode template ", valueof(p_geoNetworkingInd));
    v_encMsg := encvalue(p_geoNetworkingInd);
      log("Encoded message:  ", bit2oct(v_encMsg));
      // Check result
      if (not isbound(v_encMsg)) {
        setverdict(fail, "Encoding failed!");
        stop;
      }
      if (ispresent(v_tr.bs)) {
        if (not match(v_encMsg, p_expEncMsg)) {
          log("Expected message: ", bit2oct(valueof(p_expEncMsg)));
          setverdict(fail, "Encoding failed, not the expected result!");
          stop;
        }
      }
      setverdict(pass, "Encoding passed.");
    
      // Check decoding
      if (p_decode == true) {
      v_res := decvalue(v_encMsg, v_decMsg);
        log("Decoded message: ", v_decMsg);
        select (v_res) {
        case (0) {
          if(match(v_decMsg, p_geoNetworkingInd)) {
            setverdict(pass);
          } else {
            setverdict(fail);
          }
        }
        case (1) {
          setverdict(fail, "Decoding failed.");
        }
        case (2) {
          setverdict(fail, "Not enough bits.");
        }
        }
      }
            
    } // End of function TestGeoNetworkingInd
        
    function TestDecodeGeoNetworkingInd(
                                        in template GeoNetworkingInd p_geoNetworkingInd, 
                                        in template (present) octetstring p_expEncMsg
                                        ) runs on TCType {
      var GeoNetworkingInd v_decMsg;
      var bitstring v_encMsg := oct2bit(valueof(p_expEncMsg));
      var integer v_res := 0;
    
    v_res := decvalue(v_encMsg, v_decMsg);
      select (v_res) {
      case (0) {
        log("p_geoNetworkingInd: ", p_geoNetworkingInd);
        log("v_decMsg          : ", v_decMsg);
        if(match(valueof(v_decMsg), p_geoNetworkingInd)) {
          setverdict(pass);
        } else {
          setverdict(fail);
        }
      }
      case (1) {
        setverdict(fail, "Decoding failed.");
      }
      case (2) {
        setverdict(fail, "Not enough bits.");
      }
      } // End of 'select' statement
            
    } // End of function TestDecodeGeoNetworkingReq
        
  } // End of group encdec_functions 
  
  control {
    execute(tc_GeoNetReq_AnycastPacket());
    execute(tc_GeoNetReq_BroadcastPacket());
    execute(tc_GeoNetReq_UnicastPacket());
    execute(tc_GeoNetReq_BeaconPacket());
    execute(tc_GeoNetReq_LsRequestPacket());
    execute(tc_GeoNetReq_LsReplyPacket());
    execute(tc_GeoNetInd_AnycastPacket());
    execute(tc_GeoNetInd_BroadcastPacket());
    execute(tc_GeoNetInd_ShbPacket());
    execute(tc_GeoNetInd_UnicastPacket());
    execute(tc_GeoNetInd_BeaconPacket());
    /*execute(tc_GeoNet_Port());
    execute(tc_GeoNet_Port_utPort());
    execute(tc_GeoNet_acPort_getLongPositionVector_1());
    execute(tc_GeoNet_acPort_getLongPositionVector_2());
    execute(tc_GeoNet_Port_acPort_beaconing_1());
    execute(tc_GeoNet_Port_acPort_beaconing_2());
    execute(tc_GeoNet_Port_acPort_pass_beaconing_1());
    execute(tc_GeoNet_Port_acPort_pass_beaconing_2());*/
    execute(tc_GeoNet_UtGnInitialize());
    execute(tc_GeoNet_UtGnChangePosition());
    execute(tc_GeoNet_UtGnTrigger_GeoUnicast_1());
    execute(tc_GeoNet_UtGnTrigger_GeoUnicast_2());
    execute(tc_GeoNet_UtGnTrigger_GeoBroadcast_1());
    execute(tc_GeoNet_UtGnTrigger_GeoBroadcast_2());
    execute(tc_GeoNet_UtGnTrigger_GeoAnycast_1());
    execute(tc_GeoNet_UtGnTrigger_GeoAnycast_2());
    execute(tc_GeoNet_UtGnTrigger_Shb_1());
    execute(tc_GeoNet_UtGnTrigger_Shb_2());
    execute(tc_GeoNet_UtGnTrigger_Tsb_1());
    execute(tc_GeoNet_UtGnTrigger_Tsb_2());
  }
  
} // End of module TestCodec_GeoNetworking
