Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » TTCN-3 decoding hypothesis(ETSI ITS, BTP protocol)
TTCN-3 decoding hypothesis [message #1755105] Tue, 28 February 2017 08:24 Go to next message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 33
Registered: June 2016
Hi All,

I have some questions regarding RAW decoding.
My situation is the following:
1) I want to decode ETSI ITS BTP layer. This BTP layer can beof type BTP-A or BTP-B;
2) In my file, I have an Event_Handler method which processes incoming BTP packets;
3) This method also calls the RAW decoding method based of the BTP port type;
3) Based on TTCN-3 TCI standard, I have a decoding hypothesis which indicates me the expected typing to be decoded

So here is my issue: The Event_Handler method has no information to select which kind of BTP is expected by the TTCN-3 receive() function (BTP-A or BTP-B). It is decoded as BTP-A. So, in my test case, if I'm expected a BTP-A, it's OK, the test is PASS. Unfortunately, if I'm expecting a BTP-B, the test is FAIL.

May I ask you some hints to fix these kinds of decoding issues?

Many thanks in advance for your support,

Best regards,

Yann Garcia
Senior Software Engineer
7 rue Soutrane - Garbejaire
F-06560 Sophia Antipolis cedex, FRANCE
Tel: +33 (0)4 93 95 82 93
Tel: +33 (0)4 92 94 49 08
Mobile: +33 (0)7 61 00 77 05
Skype: yann.garcia
Re: TTCN-3 decoding hypothesis [message #1755112 is a reply to message #1755105] Tue, 28 February 2017 08:46 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 709
Registered: January 2015
Senior Member
Hi Yann,

according to :

ETSI TS 102 636-5-1 V1.1.1 (2011-02)
Technical Specification
Intelligent Transport Systems (ITS);
Vehicular Communications;
Part 5: Transport Protocols;
Sub-part 1: Basic Transport Protocol


Lenard will give you details about encoding/decoding BTP.

Best regards

  • Attachment: BTP.png
    (Size: 28.41KB, Downloaded 190 times)
Re: TTCN-3 decoding hypothesis [message #1755121 is a reply to message #1755105] Tue, 28 February 2017 09:24 Go to previous messageGo to next message
Lenard Nagy is currently offline Lenard NagyFriend
Messages: 13
Registered: September 2016
Junior Member
Hi Yann,

This problem we have solved in this code with the variant specifications handled by Titan's RAWencoder:


type record ExtBtpPayload {
  //DecodedBtpPayload decodedPayload optional,
  BtpRawPayload rawPayload
} with { variant "" };

type record ExtBtpReq {
  OCT1           nextheader,
  BtpHeader      header,
  ExtBtpPayload  payload optional
} with { variant (header)  "CROSSTAG( btpAHeader, nextheader = '01'O; 
  btpBHeader, nextheader = '02'O; )"  };

external function f_enc_ExtBtpReq(in ExtBtpReq pdu) return octetstring

with { extension "prototype(convert)"
  extension "encode(RAW)"

function f_enc_BtpReq(in BtpReq pdu) return octetstring

  var ExtBtpReq v_ExtBtpReq


  //Temporary hack 

  return f_enc_ExtBtpReq(v_ExtBtpReq);

type record ExtBtpInd {
  OCT1           nextheader,
  BtpHeader      header,
  octetstring    rawPayload optional
} with { variant (header)  "CROSSTAG( btpAHeader, nextheader = '01'O; 
  btpBHeader, nextheader = '02'O; )"  };

external function f_dec_ExtBtpInd(in octetstring stream) return ExtBtpInd
with { extension "prototype(convert)"
  extension "decode(RAW)"
  extension "errorbehavior(ALL:WARNING)"

function f_dec_BtpInd(in octetstring stream) return BtpInd {

  var ExtBtpInd v_ExtBtpInd:=f_dec_ExtBtpInd(stream)

  var BtpInd v_BtpInd

  if (ispresent(v_ExtBtpInd.rawPayload)) {

    var DecodedBtpPayload v_decodedPayload;
    if (v_ExtBtpInd.nextheader == '01'O) { //BTP A Header
      v_decodedPayload := 
    } else if (v_ExtBtpInd.nextheader == '02'O) { //BTP B Header
      v_decodedPayload := 

    if (isbound(v_decodedPayload)) {
      v_BtpInd.msgIn.payload.decodedPayload := v_decodedPayload;
    } else {
      v_BtpInd.msgIn.payload.decodedPayload := omit;
  } else
    v_BtpInd.msgIn.payload := omit;

  return v_BtpInd


function decodeBTPPayload(octetstring rawPayload, integer destinationPort) 
  return DecodedBtpPayload {
    var DecodedBtpPayload v_decodedPayload;
    if (destinationPort == 2001) 
      v_decodedPayload := { camPacket := dec_CAM_PDU(rawPayload)}
    } else if (destinationPort == 2002) {
      v_decodedPayload := { denmPacket := dec_DENM_PDU(rawPayload)}
    } else if (destinationPort == 2003) {
      v_decodedPayload := { mapPacket := dec_MAP_PDU(rawPayload)}
    } else if (destinationPort == 2004) {
      v_decodedPayload := { spatPacket := dec_SPAT_PDU(rawPayload)}
    } //TODO: Handle destinationPort == 2005
    return v_decodedPayload;

function isWellKnownBTPPort(integer prt) return boolean {
  return ((prt >= 2001) and (prt <= 2005));


In our code we create overlay data structures (ExtBtp*) to be able to decode the actual message and then we copy the data fields to the original ETSI data structures in a function called by the testport. (This would not be needed should the original ETSI data types have the encoding specifications on them)

As stated in ETSI EN 302 636-5-1 V1.2.1 (BTP protocol description) the BTP header type can be identified by the NextHeader field in the CommonHeader in the GN headers, which always precedes a BTP header.

Lenard Nagy
Re: TTCN-3 decoding hypothesis [message #1756036 is a reply to message #1755112] Fri, 10 March 2017 10:01 Go to previous message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 33
Registered: June 2016
Hello Elemer, Lenard,

Sorry for the delay.
Many thanks for your help,

Previous Topic:Using TLS/DTLS with Titan test ports part 4
Next Topic:CoAP, MQTT and LWM2M TTCN-3 test case examples
Goto Forum:

Current Time: Thu Mar 22 19:58:15 GMT 2018

Powered by FUDForum. Page generated in 0.01935 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software