Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » TTCN-3 template question
TTCN-3 template question [message #1779778] Fri, 12 January 2018 13:33 Go to next message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 63
Registered: June 2016
Member
Hello,

I have a stupid question: in TITAN, How can I to specify an octetstring template starting with the fixed sequence '07D20000'O followed by one or more bytes.
I tried these:
1) var template octetstring v_out := '07D200'O & ? length (5..1024);
2) var template octetstring v_out := '07D200'O & *;
3) var template octetstring v_out := '07D200*'O

In all case I got a compiler error.

Has anyone any idea?

Many thanks in advance for your help,

Yann
Re: TTCN-3 template question [message #1779779 is a reply to message #1779778] Fri, 12 January 2018 13:43 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 851
Registered: January 2015
Senior Member
Hi Yann,


the third option is correct and it works for me:

module Tempest
{



template octetstring v_out2 := '07D200*'O 

control{


var template octetstring v_out3 := '07D200*'O ;


}

} 



compiles with no error with CRL 113 200/6 R3B

What error do you get?


Best regards

Elemer



Re: TTCN-3 template question [message #1779781 is a reply to message #1779779] Fri, 12 January 2018 13:57 Go to previous messageGo to next message
roland gecse is currently offline roland gecseFriend
Messages: 9
Registered: December 2015
Junior Member
Minor correction:
Template '07D200*'O matches any octetstring beginning with '07D200'O prefix.
Template '07D200?*'O would match _one or more_ octets following the prefix.
Re: TTCN-3 template question [message #1779820 is a reply to message #1779781] Sat, 13 January 2018 10:41 Go to previous messageGo to next message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 63
Registered: June 2016
Member
Hello,

Thanks a lot.
You're right it works in this way, but my question was not clear.
I want to build the template dynamically, such as:
            var octetstring v_t1 := int2oct(p_dst_port, 2) & int2oct(p_src_port, 2);
            var template octetstring v_out := v_t1 & '?*'O;

In this case, I got the error message "error: at or before token `'O': syntax error, unexpected OctetStringMatch"

I tried also this:
            var octetstring v_t1 := int2oct(p_dst_port, 2) & int2oct(p_src_port, 2);
            var template octetstring v_out := v_t1 & ? & *;

and I got the error message "error: any or omit with no length restriction is not a valid concatenation operand"

Has anyone any idea?

Many thanks in advance for your help,

Yann
Re: TTCN-3 template question [message #1779821 is a reply to message #1779781] Sat, 13 January 2018 10:41 Go to previous messageGo to next message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 63
Registered: June 2016
Member
Hello,

Thanks a lot.
You're right it works in this way, but my question was not clear.
I want to build the template dynamically, such as:
            var octetstring v_t1 := int2oct(p_dst_port, 2) & int2oct(p_src_port, 2);
            var template octetstring v_out := v_t1 & '?*'O;

In this case, I got the error message "error: at or before token `'O': syntax error, unexpected OctetStringMatch"

I tried also this:
            var octetstring v_t1 := int2oct(p_dst_port, 2) & int2oct(p_src_port, 2);
            var template octetstring v_out := v_t1 & ? & *;

and I got the error message "error: any or omit with no length restriction is not a valid concatenation operand"

Has anyone any idea?

Many thanks in advance for your help,

Yann
Re: TTCN-3 template question [message #1779826 is a reply to message #1779821] Sat, 13 January 2018 17:28 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 851
Registered: January 2015
Senior Member
Hi Yann,

the answer to this is a bit counterintuitive.

To derive it, we have to look into the paragraph
15.11 Concatenating templates of string and list types
of the standard, which says:


Templates of string and list types (bitstring, octetstring, hexstring, charstring, universal charstring, record of, set of, and
array) can be concatenated from several single (in-line) templates using the concatenation operation. With the exception
of charstring and universal charstring templates, each single template shall have the same root type. The single
templates of binary string and list types shall contain only the matching mechanisms specific values, AnyValue without
a length modifier, AnyValue or AnyValueOrNone, both constrained to a fixed length, AnyElement or
AnyElementsOrNone possibly constrained with a length attribute for list types.
...
The concatenation results in the sequential concatenation of the single templates from left to right, with two exceptions:
matching symbol AnyValue without a length modifier shall be replaced by a single AnyElementsOrNone matching symbol before concatenation and matching symbols AnyValue and AnyValueOrNone that are each constrained to a fixed length N shall be replaced by N AnyElement matching symbols before concatenation. The concatenation shall be
performed completely before using the resulting template (e.g. for assignment or matching) and the result shall be typecompatible
with the place of its use.


So in a concatenation we can have:
-specific values
-AnyValue without a length modifier, that is '?'
-AnyValue with a length modifier, that is '? length (n)' (fixed)
-AnyValueOrNone with a length modifier, that is '* length (n)' (fixed)

according to the above:
-'?' will be converted to *
-'* length (n)' will be converted to '? length (n)'


For the first conversion, see also EXAMPLE 1
template octetstring mw_myoct1 := 'ABCD'O & 'EF'O & ? & ? length(1) & 'EF'O;
 // results in the template 'ABCDEF*?EF'O
 // note that & ? & turns to * within the resulting octetstring as the original ?
 // stands for an octetstring of any length  


This means that you will need a template as below:
template octetstring t_out5(integer p_dst_port, integer p_src_port ) := int2oct(p_dst_port, 2) & int2oct(p_src_port, 2) & ? length(1) & ? ; 


I tried to illustrate this in the attached code:

module Tempest
{

/*

15.11 Concatenating templates of string and list types 

Templates of string and list types (bitstring, octetstring, hexstring, charstring, universal charstring, record of, set of, and
array) can be concatenated from several single (in-line) templates using the concatenation operation. With the exception
of charstring and universal charstring templates, each single template shall have the same root type. The single
templates of binary string and list types shall contain only the matching mechanisms specific values, AnyValue without
a length modifier, AnyValue or AnyValueOrNone, both constrained to a fixed length, AnyElement or
AnyElementsOrNone possibly constrained with a length attribute for list types. 
...
The concatenation results in the sequential concatenation of the single templates from left to right, with two exceptions:
matching symbol AnyValue without a length modifier shall be replaced by a single AnyElementsOrNone matching
symbol before concatenation and matching symbols AnyValue and AnyValueOrNone that are each constrained to a fixed
length N shall be replaced by N AnyElement matching symbols before concatenation. The concatenation shall be
performed completely before using the resulting template (e.g. for assignment or matching) and the result shall be typecompatible
with the place of its use. 



-specific value
-? ---> *
-? length (n)  --> ??..?  (n times) 
-* length (n)  --> ??..?  (n times) 


template octetstring mw_myoct1 := 'ABCD'O & 'EF'O & ? & ? length(1) & 'EF'O;
 // results in the template 'ABCDEF*?EF'O
 // note that & ? & turns to * within the resulting octetstring as the original ?
 // stands for an octetstring of any length 

*/ 

template octetstring t_out0 := '07D200*'O; 
template octetstring t_out1 := '07D200?*'O 
template octetstring t_out2 := '07D200'O & ? length (2); 
template octetstring t_out3 := '07D200'O & * length (2);  // * length(2) is replaced by ? length 2 
template octetstring t_out4 := '07D200'O & ? length (1) & ? ; //? replaced by *
template octetstring t_out5(integer p_dst_port, integer p_src_port ) := int2oct(p_dst_port, 2) & int2oct(p_src_port, 2) & ? length(1) & ? ;


control{

var integer v_dst_port:=2002,v_src_port:=0

var template octetstring v_out0 := '07D200*'O; 
var template octetstring v_out1 := '07D200?*'O 
var template octetstring v_out2 := '07D200'O & ? length (2); 
var template octetstring v_out3 := '07D200'O & * length (2); 
var template octetstring v_out4 := '07D200'O & ? length (1) & ? ; 
var template octetstring v_out5 := int2oct(v_dst_port, 2) & int2oct(v_src_port, 2) & ? length(1) & ? ;


log(t_out0)
log(t_out1)
log(t_out2)
log(t_out3)
log(t_out4)
log(t_out5(2002,0))



log(match('07D20000BB'O,t_out0))
log(match('07D20000BB'O,t_out1))
log(match('07D20000BB'O,t_out2))
log(match('07D20000BB'O,t_out3))
log(match('07D20000BB'O,t_out4))
log(match('07D20000BB'O,t_out5(2002,0)))

}

} 



which , when executed , will result in:

18:15:35.396882 TTCN-3 Main Test Component started on GlobalWarning1. Version: CRL 113 200/6 R3B.
18:15:35.397023 TTCN Logger v2.2 options: TimeStampFormat:=Time; LogEntityName:=No; LogEventTypes:=No; SourceInfoFormat:=None; *.FileMask:=LOG_ALL; *.ConsoleMask:=ACTION | ERROR | TESTCASE | STATISTICS_VERDICT | STATISTICS_UNQUALIFIED | WARNING; LogFileSize:=0; LogFileNumber:=1; DiskFullAction:=Error
18:15:35.397205 Connected to MC.
18:15:35.397839 Executing control part of module Tempest.
18:15:35.397894 Execution of control part in module Tempest started.
18:15:35.397977 '07D200*'O
18:15:35.398019 '07D200?*'O
18:15:35.398048 '07D200??'O
18:15:35.398081 '07D200??'O
18:15:35.398113 '07D200?*'O
18:15:35.398139 '07D20000?*'O
18:15:35.398168 '07D20000BB'O with '07D200*'O matched
18:15:35.398202 '07D20000BB'O with '07D200?*'O matched
18:15:35.398232 '07D20000BB'O with '07D200??'O matched
18:15:35.398261 '07D20000BB'O with '07D200??'O matched
18:15:35.398289 '07D20000BB'O with '07D200?*'O matched
18:15:35.398317 '07D20000BB'O with '07D20000?*'O matched
18:15:35.398355 Execution of control part in module Tempest finished.
18:15:35.398727 Verdict statistics: 0 none, 0 pass, 0 inconc, 0 fail, 0 error.
18:15:35.398814 Test execution summary: 0 test case was executed. Overall verdict: none
18:15:35.398857 Exit was requested from MC. Terminating MTC.



Now, there is a twist to the story you should be aware of: Titan will align to this part of the standard only in Runtime 2 , the function test runtime; in Runtime 1 ( load test runtime) it will use a simplified interpretation of the standard for speed reasons.


This means that you will have to switch your project to Runtime 2 ; this will cause some reduction of execution speed you will probably not notice, unless you are running performance tests, which I doubt.

To do this you will have to do the following modifications in your Makefile (after running a make clean first of course)

1. add -DTITAN_RUNTIME_2 to CPPFLAGS:
# Flags for the C++ preprocessor (and makedepend as well):
CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)/include   -DTITAN_RUNTIME_2
 



2. add -R to compiler flags:
# Flags for the TTCN-3 and ASN.1 compiler:
COMPILER_FLAGS = -L -R
 


3.change TTCN3_LIB to ttcn3-rt2 or ttcn3-rt2-parallel (from ttcn3 or ttcn3-parallel)
# Execution mode: (either ttcn3 or ttcn3-parallel)
TTCN3_LIB = ttcn3-rt2-parallel
  




I hope this helps

BR

Elemer

[Updated on: Sat, 13 January 2018 17:33]

Report message to a moderator

Re: TTCN-3 template question [message #1779885 is a reply to message #1779826] Mon, 15 January 2018 10:20 Go to previous message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 63
Registered: June 2016
Member
Hello Elemer,

Yes, you really help me ;)

Thanks a lot,

Yann
Previous Topic:Lego Bob strikes again
Next Topic:Default Parameters in Template Bug ?
Goto Forum:
  


Current Time: Wed Nov 14 01:03:54 GMT 2018

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

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

Back to the top