Home » Eclipse Projects » Eclipse Titan » Default as Omit not working in TTCN 3 test cases(Compiling 3gpp lte TTCN-3 test cases)
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1714583 is a reply to message #1714488] |
Fri, 13 November 2015 17:03 |
Gyorgy Rethy Messages: 31 Registered: April 2015 |
Member |
|
|
Hi Muhammad,
Actually, the -d compiler switch and the related Eclipse setting are related to ASN.1 SEQUENCE/SET fields with DEFAULT values. If the field is not present in the TTCN-3 value/tempate Titan can either insert the ASN.1 default value or "really" omit the field at encoding.
Titan supports both omit as formal parameters' default value and passing omit to formal parameters with default value. But, according to the standard, the formal parameter shall be at least of "template(omit)" kind.
Could you include a concrete example from the code you are having a trouble with?
BR, Gyorgy
[Updated on: Fri, 13 November 2015 17:21] Report message to a moderator
|
|
|
Re: Default as Omit not working in TTCN 3 test cases [message #1714701 is a reply to message #1714583] |
Mon, 16 November 2015 06:34 |
Muhammad Uzair Messages: 35 Registered: November 2015 |
Member |
|
|
Hi,
Thanks for your quick help.
-d compiler switch is not working.
I am setting the -d compiler switch on project creation and also sets it in windows--> Preferences --> Titan Preferences --> Titan actions (Default as omit checked).
I have also checked that its present in make file from the time of its creation:
# Flags for the TTCN-3 and ASN.1 compiler:
COMPILER_FLAGS = -dlL
Here is an example from the 3gpp test cases:
"sttdIndicator" is passed as omit in following code:
template (value) RL_Setup_FDD_PhysicalChannelInfo_Type cs_SS_E_AGCH_Info_FDD :=
{ /* @status APPROVED */
e_AGCHInfo := {
r8 := {
e_AGCHInfo := cs_E_AGCH_Info_FDD_r8,
tti := f_Get_EDCH_TTI_Value(),
e_AGCH_PowerOffset := tsc_E_AGCH_PowerOffset,
e_RNTI_Primary := tsc_E_RNTI,
e_RNTI_Secondary := omit,
ss_DTX_Info := omit,
initialServingGrantValue := omit,
sttdIndicator := omit
}
}
};
This parameter is defined here and have a default value of false:
r8 SEQUENCE {
e-AGCHInfo E-AGCH-Information-r8,
tti E-DCH-TTI,
e-AGCH-PowerOffset INTEGER (0..255),
-- Range and Step are FFS (25.433, 9.2.2.13If)
-- Offset relative to P-CPICH
e-RNTI-Primary E-RNTI OPTIONAL,
e-RNTI-Secondary E-RNTI OPTIONAL,
ss-DTX-Info DRX-Info OPTIONAL,
initialServingGrantValue INTEGER (0..37) OPTIONAL,
sttdIndicator BOOLEAN DEFAULT FALSE -- @sic R5-120613 sic@
},
Text of error is "'omit' value is not allowed in this context"
Please help me in identifying the problem.
Thanks,
Muhammad Uzair
|
|
| | |
Re: Default as Omit not working in TTCN 3 test cases [message #1714841 is a reply to message #1714827] |
Tue, 17 November 2015 08:04 |
|
Hi Muhammad,
I have made two compilations, one with
# Flags for the TTCN-3 and ASN.1 compiler:
COMPILER_FLAGS = -L -l -d -M -w (see comp1.txt)
and one with
# Flags for the TTCN-3 and ASN.1 compiler:
COMPILER_FLAGS = -L -l -M -w (without -d , see comp2.txt)
As you can see,
error: `omit' value is not allowed in this context
appears only in comp2.txt , so -d works as expected.
There are other errors that will have to be cleared one by one before you
can continue.
One more thing: you are working with radio protocols, and most of the time, due to scarcity of radio resources, these use PER-encoding; Titan does not have a native PER codec; for a workaround , pls. see the previous post
https://www.eclipse.org/forums/index.php/t/1070344/
Best regards
Elemer
-
Attachment: comp1.txt
(Size: 106.01KB, Downloaded 331 times) -
Attachment: comp2.txt
(Size: 485.86KB, Downloaded 174 times)
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1715037 is a reply to message #1715010] |
Wed, 18 November 2015 17:01 |
|
Hi Muhammad,
Titan does not have a native PER-codec, so it has to rely on an external solution.
The workflow we use is as follows:
-for the sending (encoding ) direction:
1. first the structure (template, variable ) is encoded in BER and passed to the external 3rd party ASN.1 compiler
2. The external compiler decodes the BER and re-encodes it into PER
-for the receiving (decoding) direction:
1. the PER -coded message is received, decoded and re-encoded in BER
2.Titan decodes the BER into the corresponding structure
From the users' point of view , these two steps appear as one function call for encoding and one for decoding, so all this complexity is not visible.
The external ASN.1 compiler can be:
-the open source asn1c (https://lionet.info/asn1c/compiler.html) , which has the disadvantage that has limitations in processing the ASN.1 code
-a commercial compiler , such as OSS Nokalva's
So to find out if asn1c is an alternative for you , please try to compile your ASN.1 code with asn1c ; if this is successful, than you can use it to generate the PER-codecs;
if not , then you will have to buy and use a commercial alternative.
For details, please see the previous post:
https://www.eclipse.org/forums/index.php/t/1070344/
The example described there , and the attached code can be used for any of the above alternatives, with the appropriate modifications.
Best regards
Elemer
|
|
| | |
Re: Default as Omit not working in TTCN 3 test cases [message #1715721 is a reply to message #1715714] |
Wed, 25 November 2015 13:26 |
|
Hi Muhammad,
let me start with #2:
For ASN.1 files, the simple answer is that you can't and you don't ; if you have a type TYPE1 declared in an ASN.1 file, to encode it , you need to declare an external function that does the encoding/decoding, be that BER (which is autogenerated) or PER (which has to be implemented externally).
Titan will ignore encoding instructions attached to modules, or will throw an error, so those will have to be commented out.
For TTCN files, it's different. TTCN code can have several types of encoding rules, RAW (binary) , TEXT (ascii) , and XER (XML). I think we can safely ignore XML here.
TTCN files can have a 'with { encoding "RAW"}' or 'with {encoding "TEXT "} ' final instruction , but, besides that, the code has to be decorated with detailed instructions of how the structures have to be encoded.
For RAW, please see the 4-part series about the binary RAW encoder of Titan in this forum; for TEXT , see the reference guide.
Now, about #1: your encoding instructions are not standard (as theses are not standardized) but are coming from a tool different from Titan; Titan will not acknowledge these ; instead they will have to be replaced with Titan's native codecs;
Many of the protocol modules listed here (DHCPv4, DNS, ICMPv6, SIP etc. ) appear as part of the Titan toolbox, see https://github.com/eclipse/titan.core, protocol modules.
Even if you don't use them directly, they might be a source of inspiration regarding how the RAW ( DHCP, ICMP) or TEXT (SIP) codecs have to be declared and defined.
In case you have these codecs from the other tool in say C++ code, they can be re-used as external functions, you are not locked in into Titan's native codecs.
However the encoding references are not valid and have to be changed to function references.
Please read through the indicated material , that should clarify the details.
Best regards
Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1715784 is a reply to message #1715778] |
Thu, 26 November 2015 08:57 |
|
Hi Muhammad,
I believe we should proceed carefully:
-the first thing you want to check is if the 'ready-made' Titan protocol module has the revision you need; typically the reference documentation is indicated in the document header
( for ICMPv6 is "RFC 4443 , RFC 4861" ), but the attached documentation will give you more detail
-if this is OK, you can add the src files to your project ; I would advise not to take any shortcuts in the beginning and simply copy the src file into your project then add them to the Makefile
( for ICMPv6 , this means two files, ICMPv6_Types.ttcn, and ICMPv6_EncDec.cc );
-now comes the tricky part : you have to identify in your code the places where ICMPv6 is used, possibly change or add import statement wherever necessary, to import the content from ICMPv6_Types.ttcn;
and also you have to identify places in the code where encoding/decoding is activated and insert references to the imported enc/dec functions f_enc_PDU_ICMPv6, f_dec_PDU_ICMPv6;
this (depending on the implementation) may appear implicitly in your code , or it may be part of the test port , so it may not be visible from the TTCN-3 code; if it's the latter, you may want to refer the codecs from your test port
I hope this makes it more clearer ; I know it's quite complicated, but please take a look on the projects I have published in this forum for more clarity
Best regards
Elemer
|
|
|
Re: Default as Omit not working in TTCN 3 test cases [message #1716011 is a reply to message #1715784] |
Mon, 30 November 2015 14:18 |
Muhammad Uzair Messages: 35 Registered: November 2015 |
Member |
|
|
Hi Elemer,
Thanks for your very helpful response. While I was going through the examples you have point out (specifically DNS example, https://github.com/eclipse/titan.core). I have came across that it is very similar to mine ( with the exception of names). Here is the DNS_TypeDefs.ttcn
module DNS_TypeDefs {
import from CommonDefs all;
const B4_Type tsc_DNSOPCODE_QUERY := '0000'B;
const B4_Type tsc_DNSOPCODE_IQUERY := '0001'B;
const B4_Type tsc_DNSOPCODE_STATUS := '0010'B;
const B4_Type tsc_DNSRCODE_NoError := '0000'B;
const B4_Type tsc_DNSRCODE_FormatError := '0001'B;
const B4_Type tsc_DNSRCODE_ServerFailure := '0010'B;
const B4_Type tsc_DNSRCODE_NameError := '0011'B;
const B4_Type tsc_DNSRCODE_NotImplemented := '0100'B;
const B4_Type tsc_DNSRCODE_Refused := '0101'B;
const O2_Type tsc_DNSTYPE_A := '0001'O;
const O2_Type tsc_DNSTYPE_NS := '0002'O;
const O2_Type tsc_DNSTYPE_MD := '0003'O;
const O2_Type tsc_DNSTYPE_MF := '0004'O;
const O2_Type tsc_DNSTYPE_CNAME := '0005'O;
const O2_Type tsc_DNSTYPE_SOA := '0006'O;
const O2_Type tsc_DNSTYPE_MB := '0007'O;
const O2_Type tsc_DNSTYPE_MG := '0008'O;
const O2_Type tsc_DNSTYPE_MR := '0009'O;
const O2_Type tsc_DNSTYPE_NULL := '000A'O;
const O2_Type tsc_DNSTYPE_WKS := '000B'O;
const O2_Type tsc_DNSTYPE_PTR := '000C'O;
const O2_Type tsc_DNSTYPE_HINFO := '000D'O;
const O2_Type tsc_DNSTYPE_MINFO := '000E'O;
const O2_Type tsc_DNSTYPE_MX := '000F'O;
const O2_Type tsc_DNSTYPE_TXT := '0010'O;
const O2_Type tsc_DNSTYPE_AAAA := '001C'O; // IPv6 address, RFC 3596
const O2_Type tsc_DNSTYPE_SRV := '0021'O; // Server selection, RFC 2782
const O2_Type tsc_DNSTYPE_NAPTR := '0023'O; // Naming Authority Pointer, RFC 3403
const O2_Type tsc_DNSTYPE_AXFR := '00FC'O; // RFC 1035 RFC 3.2.3
const O2_Type tsc_DNSTYPE_MAILB := '00FD'O;
const O2_Type tsc_DNSTYPE_MAILA := '00FE'O;
const O2_Type tsc_DNSTYPE_ALL := '00FF'O;
const O2_Type tsc_DNSCLASS_IN := '0001'O;
type record DNSMessage { // RFC 1035 clause 4
DNS_Header dnsHeader,
DNS_Questions questions optional,
DNS_RRs answer optional,
DNS_RRs authority optional,
DNS_RRs additional optional
};
type record DNS_Header { // RFC 1035 clause 4.1.1
O2_Type id,
B1_Type qr, // 0 message is a query, 1 message is a response
B4_Type opcode, // 0 QUERY, 1 IQUERY, 2 STATUS, 3-15 reserved
B1_Type aa, // Authoritative Answer
B1_Type tc, // Truncation
B1_Type rd, // Recursion desired
B1_Type ra, // Recursion available
B3_Type z, // reserved, must be 0 in all queries and responses
B4_Type rcode, // Response code
UInt16_Type qdcount, // number of entries in the question section
UInt16_Type ancount, // number of RRs in the answer section
UInt16_Type nscount, // number of RRs in the auth. records section
UInt16_Type arcount // number of RRs in the additional records section
};
type record of DNS_Question DNS_Questions;
type record DNS_Question { // RFC 1035 clause 4.1.2
octetstring qname,
O2_Type qtype,
O2_Type qclass
};
type record of DNS_RR DNS_RRs;
type record DNS_RR { // RFC 1035 clause 4.1.3
octetstring name,
O2_Type rrtype,
O2_Type class,
UInt32_Type ttl,
UInt16_Type rdlength,
DNS_RDATAu rdata // union of different types
};
type union DNS_RDATAu {
DNS_A_RR a, // RFC 1035 clause 3.4.1, A 32 bit Internet Address
/* DNS_PTR_RR ptr, // RFC 1035 clause 3.3.12 */
/* DNS_NAPTR_RR naptr, // RFC 3403 clause 4.1 */
DNS_AAAA_RR aaaa // RFC 3596
/* DNS_SRV_RR srv // RFC 2782 */
};
/* type record DNS_PTR_RR { // RFC 1035 clause 3.3.12 */
/* charstring ptrdname */
/* }; */
/* type record DNS_NAPTR_RR { // RFC 3403 clause 4.1 */
/* UInt16_Type order, */
/* UInt16_Type preference, */
/* charstring flags optional, */
/* charstring services optional, */
/* charstring dnrr_regexp optional, */
/* charstring replacement optional */
/* }; */
type record DNS_AAAA_RR { // RFC 3596 clause 2.2
O16_Type ipv6addr
};
type record DNS_A_RR { // RFC 1035 clause 3.4.1, A 32 bit Internet Address
O4_Type ipv4addr
};
/* type record DNS_SRV_RR { // RFC 2782 (but where exactly is the format specification?) */
/* UInt16_Type priority, */
/* UInt16_Type weight, */
/* UInt16_Type srvport, */
/* charstring target */
/* }; */
} with {encode "DNS-Codec"}
I was having following error in line 57 (type record DNSMessage)
Unknown encoding 'DNS-Codec'
Since this field (with {encode "DNS-Codec"}) is optional and not present in DNS example, so I removed it.
Now I am having following error in line 57 (type record DNSMessage)
No coding rule specified for type '@DNS_TypeDefs.DNSMessage'
All of the parameters in this file are properly defined similar to your example. I am including some of the types as an example, define in CommonDefs.ttcn
type bitstring B1_Type length(1);
type bitstring B2_Type length(2);
type bitstring B3_Type length(3);
type bitstring B4_Type length(4);
type B128_Type B128_Key_Type; /* 128 bit security key */
type B256_Type B256_Key_Type; /* 256 bit security key */
type octetstring O1_Type length(1);
type octetstring O2_Type length(2);
type octetstring O3_Type length(3);
type octetstring O4_Type length(4);
type octetstring O5_Type length(5);
type octetstring O16_Type length(16);
type integer UInt_Type (0 .. infinity);
type integer UInt8_Type (0 .. tsc_UInt8Max);
type integer UInt16_Type (0 .. tsc_UInt16Max);
Regarding encoding decoding DNS message, both of them are defined in other modules copied below.
function f_DomainName_Encode(charstring p_DomainName) return octetstring
{
var CharStringList_Type v_LabelList := f_StringSplit(p_DomainName, {"."});
return f_DomainName_EncodeLabels(v_LabelList);
}
function fl_DomainName_Decode(octetstring p_OctetString) return charstring
{
var CharStringList_Type v_LableList := {}
var integer i := 0;
var integer k := 0;
var integer v_StringLength := lengthof(p_OctetString);
var integer v_LableLength;
var octetstring v_EncodedLable;
while (true) {
v_LableLength := oct2int(p_OctetString[i]);
i := i + 1;
if ((v_LableLength > 0) and (i + v_LableLength < v_StringLength)) {
v_EncodedLable := substr(p_OctetString, i, v_LableLength);
i := i + v_LableLength;
v_LableList[k] := oct2char(v_EncodedLable);
k := k + 1;
} else {
break;
}
}
return f_StringJoin(v_LableList, ".");
}
Can you please point out what I am missing here? since all the definitions are there, similar to DNS example. The only difference is that some fields are declared as bit fields in my code while as int16 or so in example, which must be ok as this encoding/decoding is not standard.
Your help in this regard would be highly appreciated.
Thanks and Best Regards,
Muhammad Uzair
|
|
|
Re: Default as Omit not working in TTCN 3 test cases [message #1716017 is a reply to message #1716011] |
Mon, 30 November 2015 15:36 |
|
Hi Muhammad,
this is a good example as I'm not sure I have elaborated this option before:
-The DNS protocol module in github does not use any of Titan's native codecs (RAW or TEXT or otherwise) but a custom handwritten codec.
This is always possible, one can simply exchange internal codecs to custom ones by simply writing the corresponding external functions.
The top-level PDU (protocol data unit) is PDU_DNS:
type record PDU_DNS {
DnsHeader header,
QResourceRecords queries,
ResourceRecords answers,
ResourceRecords nameServerRecords,
ResourceRecords additionalRecords
}
(In your example , this is called DNSMessage:
type record DNSMessage { // RFC 1035 clause 4
DNS_Header dnsHeader,
DNS_Questions questions optional,
DNS_RRs answer optional,
DNS_RRs authority optional,
DNS_RRs additional optional
};
)
the corresponding codec functions are declared as external functions:
external function enc_PDU_DNS(
in PDU_DNS msg,
in boolean doCompression,
in boolean autoLengthCalc) return octetstring;
external function dec_PDU_DNS( in octetstring stream ) return PDU_DNS;
and they terminate in DNS_EncDec.cc:
PDU__DNS dec__PDU__DNS(const OCTETSTRING& stream)
{
int stream_length = stream.lengthof(), i;
const unsigned char *p_stream = stream;
const unsigned char *stream_start = p_stream;
PDU__DNS msg;
:
:
}
OCTETSTRING enc__PDU__DNS(const PDU__DNS& msg,
const BOOLEAN& doCompression,
const BOOLEAN& autoLengthCalc)
{
TTCN_Buffer stream;
unsigned char *p_stream = NULL;
int i;
:
:
}
the first one takes as input an octetstring and returns a PDU_DNS structure (decoding);
the second one takes as input a structure, and returns an octetstring
(there are additional fucntions for conecrting/encoding domain name etc., but these two are the main ones)
In your example I don't see the corresponding codec functions that would accept DNSMessage as input and return octetstring (encoding) and the opposite, accepts octetstring and returns DNSMessage(decoding) ;
and this is the exact meaning of the message:
No coding rule specified for type '@DNS_TypeDefs.DNSMessage'
Your TTCN-3 implementation probably hides encoding/decoding somewhere , maybe in the test port , and the encoding/decoding is triggered
by the with {encode "DNS-Codec"} extension; this indicates to the TTCN-3 implementation how these messages are to be encoded, but the exact details are not visible from the TTCN-3 code.
What you need to do is to write these functions in analogy with the example in github
P.S. It is not common for us to use custom functions, usually we rely on the RAW codec , as in ICMPv6 for instance(https://github.com/eclipse/titan.ProtocolModules.ICMPv6).
I hope this brings some clarity
Best regards
Elemer
|
|
| | |
Re: Default as Omit not working in TTCN 3 test cases [message #1716078 is a reply to message #1716077] |
Tue, 01 December 2015 06:12 |
Muhammad Uzair Messages: 35 Registered: November 2015 |
Member |
|
|
Hi Elemer,
Another thing is that the following function is doing encoding by creating an instance of DNS message and encoding its value, wouldn't that work?:
function f_DNS_GetEncodedResponse(octetstring p_Request,
PDN_Index_Type p_PdnIndex) return octetstring
{
var DNS_AddressResolutionTable_Type v_DNS_AddressResolutionTable := f_DNS_AddressResolutionTable(p_PdnIndex);
var bitstring v_Bitstring := oct2bit(p_Request);
var octetstring v_Response := ''O;
var DNSMessage v_DNSQuery;
var DNS_Question v_DNS_Question;
var template (value) DNSMessage v_DNS_Response;
var template (value) DNS_RRs v_DNS_RRs := {}
if (decvalue(v_Bitstring, v_DNSQuery) != 0) {
f_ErrorLog(__FILE__, __LINE__, "Cannot decode DNS query (skipped)");
return v_Response;
}
if (not match(v_DNSQuery, cr_DNS_Query)) {
f_ErrorLog(__FILE__, __LINE__, "Invalid/unexpected DNS query");
return v_Response;
}
if (v_DNSQuery.dnsHeader.qdcount > 1) {
f_ErrorLog(__FILE__, __LINE__, "multiple DNS questions not supported yet in the same query");
return v_Response;
}
v_DNS_Question := v_DNSQuery.questions[0];
if (not match(v_DNS_Question, cr_DNS_Question)) {
f_ErrorLog(__FILE__, __LINE__, "Invalid/unexpected DNS question");
return v_Response;
}
v_DNS_RRs := fl_DNS_Answer(v_DNS_Question, v_DNS_AddressResolutionTable);
if (lengthof(v_DNS_RRs) > 0) {
v_DNS_Response := cs_DNS_Reponse(v_DNSQuery, v_DNS_RRs);
v_Response := bit2oct(encvalue(v_DNS_Response));
}
return v_Response;
}
Thanks,
Uzair
|
|
|
Re: Default as Omit not working in TTCN 3 test cases [message #1716094 is a reply to message #1716078] |
Tue, 01 December 2015 09:40 |
|
Hi Muhammad,
you need to adapt the code with respect to your declarations;
for instance:
module DNS_TypeDefs {
external function enc_PDU_DNS(
in DNSMessage msg,
in boolean doCompression,
in boolean autoLengthCalc) return octetstring;
external function dec_PDU_DNS( in octetstring stream ) return DNSMessage;
import from CommonDefs all;
const B4_Type tsc_DNSOPCODE_QUERY := '0000'B;
const B4_Type tsc_DNSOPCODE_IQUERY := '0001'B;
const B4_Type tsc_DNSOPCODE_STATUS := '0010'B;
:
:
etc.
is OK, although enc_DNSMessage , dec_DNSMessage would be more appropriate names for the functions.
In DNS_EncDec.cc
#include "DNS_Type.hh"
has to be changed to:
#include "DNS_TypeDefs.hh" as it has to connect to DNS_TypeDefs
With this change, if I compile , I get :
make
make: Warning: File `DNS_TypeDefs.ttcn' has modification time 1.8e+03 s in the future
/proj/TTCN/Releases/TTCNv3_daily_LMWP3.1/bin/compiler -L \
CommonDefs.ttcn DNS_TypeDefs.ttcn - DNS_TypeDefs.ttcn
Notify: Parsing TTCN-3 module `CommonDefs.ttcn'...
Notify: Parsing TTCN-3 module `DNS_TypeDefs.ttcn'...
Notify: Checking modules...
Notify: Generating code...
Notify: None of the files needed update.
touch compile
g++ -c -DLINUX -I/proj/TTCN/Releases/TTCNv3_daily_LMWP3.1/include -Wall -o DNS_EncDec.o DNS_EncDec.cc
DNS_EncDec.cc:83: error: 'ResourceRecord' has not been declared
DNS_EncDec.cc:120: error: expected ',' or '...' before '&' token
DNS_EncDec.cc:121: error: ISO C++ forbids declaration of 'ResourceRecord' with no type
DNS_EncDec.cc: In function 'DNS__TypeDefs::DNSMessage DNS__TypeDefs::dec__PDU__DNS(const OCTETSTRING&)':
DNS_EncDec.cc:145: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'header'
DNS_EncDec.cc:155: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'queries'
DNS_EncDec.cc:156: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'answers'
DNS_EncDec.cc:157: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'nameServerRecords'
DNS_EncDec.cc:158: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'additionalRecords'
DNS_EncDec.cc:161: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'header'
DNS_EncDec.cc:162: error: 'QResourceRecord' was not declared in this scope
DNS_EncDec.cc:162: error: expected `;' before 'rec'
DNS_EncDec.cc:164: error: 'rec' was not declared in this scope
DNS_EncDec.cc:171: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'queries'
DNS_EncDec.cc:181: error: 'class DNS__TypeDefs::DNSMessage' has no member named 'header'
DNS_EncDec.cc:182: error: 'ResourceRecord' was not declared in this scope
DNS_EncDec.cc:182: error: expected `;' before 'rr'
:
:
etc.
and most of the errors are there because of the invalid references to the structures from the DNS types in github:
type record PDU_DNS {
DnsHeader header,
QResourceRecords queries,
ResourceRecords answers,
ResourceRecords nameServerRecords,
ResourceRecords additionalRecords
}
but your structures are different:
type record DNSMessage { // RFC 1035 clause 4
DNS_Header dnsHeader,
DNS_Questions questions optional,
DNS_RRs answer optional,
DNS_RRs authority optional,
DNS_RRs additional optional
};
and DNSMessage indeed has no field, header, queries etc. as the field names are different;
so I'm afraid it is not enough to mechanically substitute the names , one has also to understand what the code is doing .
As for your question regarding f_DNS_GetEncodedResponse
decoding is done here:
if (decvalue(v_Bitstring, v_DNSQuery) != 0) {
and decvalue is only invoking the codec function itself which is not apparent in the code.
So in summary: you are on the right track , but you will have to rewrite the DSN_EncDec.cc to match the details of your declarations in DNS_TypeDefs.ttcn.
I hope this helps
Best regards
Elemer
|
|
| | |
Re: Default as Omit not working in TTCN 3 test cases [message #1716117 is a reply to message #1716116] |
Tue, 01 December 2015 12:01 |
|
One thing I can suggest is that you don' try to compile everything at once; try to break it down on part and compile them separately , and then add them together etc.
For instance DNS_TypeDefs.ttcn and CommonDefs.ttcn and DNS_EncDec.cc should be compileable on their own; you don't need EUTRA_RRC_ASN1_Definitions.asn for that.
BR Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1716255 is a reply to message #1716239] |
Wed, 02 December 2015 14:00 |
|
Hi Muhammad,
yes, you are going in the right direction. As I mentioned, the only reason we did not use the RAW codec for DNS was that at the time it was not ready.
And now , your questions:
1. If you want a compound type (set , record, union) etc. to be encoded with RAW, you need at least one variant attribute, even if empty:
type record Something0
{
:
}
will not be encoded, but
type record Something1
{
}
with { variant "" }
will be encoded (using the applicable defaults)
2 and 3. No, it's not sufficient to have length info only ; the length information is used by the compiler to verify during compilation (or runtime) , but the codec needs a separate FIELDLENGTH instruction:
type octetstring OCT14 length(14) with { variant "FIELDLENGTH(14)" };
please check in https://github.com/eclipse/titan.ProtocolModules.COMMON/tree/master/src
General_Types.ttcn and general_typedefs.ttcn; they will give you a pretty good idea how to encode simple types.
4. Yes, once the codec is triggered, all applicable defaults will apply.
It may seem cumbersome at first , but if you have the codec instructions in place, Titan will generate automatically the encoding-decoding functions; please be aware though that in the original encoding function:
in DNSMessage msg,
in boolean doCompression,
in boolean autoLengthCalc) return octetstring;
I see booleans that trigger compression and automatic calculation of length; RAW can do auto legnth calculation, but compression, if wanted, has to be dealt with separately.
What we usually do to verify the RAW codec is to create sample templates we encode, and then decode, and also sample binary messages ( in this case you can listen to some DNS traffic with wireshark and save some messages) which we decode.
I hope this helps
Best regards
Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1716267 is a reply to message #1716259] |
Wed, 02 December 2015 15:28 |
|
HI Muhammad,
I'm afraid there might be a problem here:
I could be wrong , but as far as I remember DL-CCCH-Message is part of the RRC protocol , which is not BER encoded, but PER encoded , which is fundamentally different;
Titan does not have a native PER -codec; an alternative solution using a 3rd part codec is described in:
https://www.eclipse.org/forums/index.php/t/1070344/
You will have to verify if asn1c (http://lionet.info/asn1c/blog/) compiles your ASN.1 code ; if this is successful, then you can assemble a PER -codec based on asn1c;
else, you will have to purchase a PER codec from a commercial ASN.1 compiler.
So please, first of all check if asn1c can be used; if yes, then follow the procedure described in the above forum post.
Best regards
Elemer
|
|
|
Re: Default as Omit not working in TTCN 3 test cases [message #1716462 is a reply to message #1716267] |
Fri, 04 December 2015 06:05 |
Muhammad Uzair Messages: 35 Registered: November 2015 |
Member |
|
|
Hi Elemer,
Thanks for your kind help. I am able to compile asn code successfully using asn1c. It generates files for decoding, encoding and header files.
I was going through the example of CAM protocol in the above mentioned link (https://www.eclipse.org/forums/index.php/t/1070344/). The C source and header files are not being referenced by any of ttcn or .cc files. Even if you remove all of them the code compiles successfully using only files (Cam.asn, ITS_Container.asn, CAM_EnDec.cc, CAM_Types.ttcn and CAM_Types_Test.ttcn). What I can understand is that external function definition present in CAM_TYPES.ttcn points to the source code present in CAM_EnDec.cc file, which encodes/decodes ASN types like any manual written coding scheme like DNS example, we discussed above. Where will be the role of files generated by asn1c?
What I can't understand is how can I use the function/files generated by asn1c to specify encoder decoder functions in ttcn source? Can I write a ttcn3 file containing the defintions of all the external functions ( genearted by asn1c for each element of asn file) and then import from this file, where ever this asn file is imported? Can you please explain the process.
Thanking you!
Best Regards,
Muhammad Uzair
|
|
|
Re: Default as Omit not working in TTCN 3 test cases [message #1716467 is a reply to message #1716462] |
Fri, 04 December 2015 08:35 |
|
Hi Muhammad,
I will walk you through the logic using CAM as example:
- first you have to compile the ASN.1 files with the gen-PER option to make sure PER codecs are generated:
asn1c gen-PER CAM.asn ITS_Container.asn
-asn1c generates a heap of files based on ASN.1, one for each type ; I guess you could put them in one big file, but at least you should put them in a separate directory to avoid messiness
-the top level PDU we want to encode/decode is CAM (CAM_PDU_Descriptions.asn):
CAM ::= SEQUENCE {
header ItsPduHeader,
cam CoopAwareness
}
-the external functions are declared in CAM_Types.ttcn :
module CAM_Types
{
import from CAM_PDU_Descriptions language "ASN.1:1997" all;
import from ITS_Container language "ASN.1:1997" all;
external function enc_CAM_PDU( in CAM pdu) return octetstring;
external function dec_CAM_PDU( in octetstring stream) return CAM;
}
- the definition of these functions is in CAM_EncDec.cc
let's see how these are connected :
I) Encoding direction : enc_CAM_PDU is called
OCTETSTRING enc__CAM__PDU(const CAM__PDU__Descriptions::CAM& pdu)
{
:
first, a BER encoding is done with Titan's native BER codec:
pdu.encode(CAM__PDU__Descriptions::CAM_descr_,TTCN_buf,TTCN_EncDec::CT_BER,BER_ENCODE_DER);
then this is decoded by asn1c:
rval = ber_decode(0, &asn_DEF_CAM, (void **)&cam, value, length);
( the referred function ber_decode is defined in ber_decoder.c, ber_decoder.h generated by asn1c
asn_dec_rval_t
ber_decode(asn_codec_ctx_t *opt_codec_ctx,
asn_TYPE_descriptor_t *type_descriptor,
void **struct_ptr, const void *ptr, size_t size) {
:
:
)
then the resulting structure is re-encoded in PER
erv = uper_encode(&asn_DEF_CAM, cam, write_out, NULL);
(the referred uper_encode is defined in per_encoder.c, per_encoder.h generated by asn1c
asn_enc_rval_t
uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {
return uper_encode_internal(td, 0, sptr, cb, app_key);
}
)
and this octetstring is returned as result
II) decoding direction
dec_CAM_PDU is called , definition is in CAM_EncDec.cc:
CAM__PDU__Descriptions::CAM dec__CAM__PDU(const OCTETSTRING& stream)
{
:
:
the incoming octetstring is per-decoded
rval = uper_decode_complete(NULL, &asn_DEF_CAM, (void **)&cam, res, res_size);
(the referred uper_decode_complete is defined in per_decoder.c, per_decoder.h generated by asn1c
asn_dec_rval_t
uper_decode_complete(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sptr, const void *buffer, size_t size) {
:
)
then re-encoded in BER :
erv = der_encode(&asn_DEF_CAM, cam, write_out, NULL);
der_encode is defined in der_encoder.c, der_encoder.h generated by asn1c
Note: DER and BER are producing equivalent encodings
)
and finally decoded by Titan's native BER :
ret_cam.decode(CAM__PDU__Descriptions::CAM_descr_,TTCN_buf,TTCN_EncDec::CT_BER,BER_ACCEPT_ALL);
which is returned as result.
Note 1: as asn1c generates C code, some tweaking is needed case-by -case to make it acceptable for g++;
I can't help you here, as it is case by case, but the examples given in the forum post should give you a hint; else, please involve someone
with extensive C/C++ knowledge.
Note 2. The reason why you managed to compile without apparently involving the asn1c-generated files is probably that you did not run make clean and the
object files generated previously were still there. After major changes, it's always a good idea to run a make clean.
Best regards
Elemer
|
|
| | |
Re: Default as Omit not working in TTCN 3 test cases [message #1716692 is a reply to message #1716683] |
Mon, 07 December 2015 14:43 |
|
Hi Muhammad,
I don't know what you mean by:"compiler is not compiling CAM_EncDec.cc file in Cam protocol example" How do you know that ? Is there any error indication? If yes, what?
-please leave aside the plug-ins for the moment and start using them only when you are familiar with the command line
-download the attachment CAM_CNL_113_xxx.tgz
and decompress it to a folder say CAM
-change directories:
-run install script
-run make
and send me the output generated
BR Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1716711 is a reply to message #1716706] |
Mon, 07 December 2015 16:37 |
|
Hi Muhammad,
thank you ; pls. post all actions and commands you execute and all responses displayed so I can figure out what's wrong;
Preferably use command line only and not the plug-ins.
BTW I have made the following experiment:
I have removed from the Makefile all .c and .h files generated by asn1c and tried to compile ;
the result was:
make
/home/james00/titan.core/Install/bin/compiler -L \
CAM_Types.ttcn CAM_Types_Test.ttcn CAM.asn ITS_Container.asn - CAM_Types.ttcn CAM_Types_Test.ttcn CAM.asn ITS_Container.asn
Notify: Parsing TTCN-3 module `CAM_Types.ttcn'...
Notify: Parsing TTCN-3 module `CAM_Types_Test.ttcn'...
Notify: Parsing ASN.1 module `CAM.asn'...
Notify: Parsing ASN.1 module `ITS_Container.asn'...
ITS_Container.asn:9: warning: Missing IMPORTS clause is interpreted as `IMPORTS ;' (import nothing) instead of importing all symbols from all modules.
Notify: Checking modules...
Notify: Generating code...
Notify: File `CAM_PDU_Descriptions.hh' was generated.
Notify: File `CAM_PDU_Descriptions.cc' was generated.
Notify: File `CAM_Types.hh' was generated.
Notify: File `CAM_Types.cc' was generated.
Notify: File `CAM_Types_Test.hh' was generated.
Notify: File `CAM_Types_Test.cc' was generated.
Notify: File `ITS_Container.hh' was generated.
Notify: File `ITS_Container.cc' was generated.
Notify: 8 files were updated.
touch compile
g++ -c -DLINUX -I/home/james00/titan.core/Install/include -I. -Wall -o CAM_Types.o CAM_Types.cc
g++ -c -DLINUX -I/home/james00/titan.core/Install/include -I. -Wall -o CAM_PDU_Descriptions.o CAM_PDU_Descriptions.cc
g++ -c -DLINUX -I/home/james00/titan.core/Install/include -I. -Wall -o ITS_Container.o ITS_Container.cc
g++ -c -DLINUX -I/home/james00/titan.core/Install/include -I. -Wall -o CAM_Types_Test.o CAM_Types_Test.cc
g++ -c -DLINUX -I/home/james00/titan.core/Install/include -I. -Wall -o CAM_EncDec.o CAM_EncDec.cc
CAM_EncDec.cc:21:17: fatal error: CAM.h: No such file or directory
#include "CAM.h"
^
compilation terminated.
make: *** [CAM_EncDec.o] Error 1
as it should be.
BR Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1716958 is a reply to message #1716808] |
Wed, 09 December 2015 10:06 |
|
Hi Muhammad,
you environment variables in Cygwin are not set correctly;
please send me the output of the following commands:
printenv | grep TTCN
printenv | grep PATH
My first recommendation is that you should use some kind of Linux instead of Cygwin, for several reasons:
-firstly, it's simpler to configure the environment
-secondly, very soon you will run into memory problems under Cygwin; I see that you need to compile UTRAN/RRC etc. protocols which are intensely consuming memory
Next, as I mentioned, try not to use the plug-ins in the beginning; the plug-ins are building upon the compiler/executor so that part shoudl be well understood and functioning perfectly before you move to the plug-ins.
Best regards
Elemer
|
|
| | |
Re: Default as Omit not working in TTCN 3 test cases [message #1716975 is a reply to message #1716972] |
Wed, 09 December 2015 11:48 |
|
Hi Muhammad,
yes, as you said, Titan is looking for the external code where the test ports are defined;
you can disable this error temporarily by making Titan believe that the test port is internal, for example:
type port UpperTesterPort message {
out UtInitialize, UtBtpTrigger;
in UtInitializeResult, UtBtpTriggerResult, UtBtpEventInd;
} with {extension "internal"}
Of course , this is not the final remedy, the test port will have to be added sooner or later; the ETSI Upper tester port sends messages over UDP so here the UDP port can be reused ( I will show you how), but other test ports can be more problematic.
Best regards
Elemer
|
|
| | | |
Re: Default as Omit not working in TTCN 3 test cases [message #1717181 is a reply to message #1717148] |
Thu, 10 December 2015 14:35 |
|
Hi Muhammad,
the first thing you will have to do is understand how your protocols are layered and how TTCN-3 is connected to the SUT.
I will assume for simplicity that all you protocols are transported over IP/Ethernet although this might not be the case.
The test ports that can be used are: TCP, UDP, IP, or LANL2 (Ethernet).
This means that you can connect to the TCP , UDP or IP layer of the IP/ETH stack or directly to Layer 2.
But of course , most of your protocols will not connect directly to any of these layers; but let's assume the simple scenario when this applies. The Upper tester messages for instance are simple structures transmitted over UDP. But all the TTCN-3 code offers is an UpperTester port, something like this:
type port UpperTesterPort message {
out
UtInitialize;
in
UtInitializeResult;
}
so somehow this port has to connect to the underlying UDP and the Upper Tester message structures in the sending direction (UtInitialize) will have to result in UDP messages, and in receiving direction , we have to extract
UtInitializeResult from the UDP frame and send it to the TTCN-3 code.
Luckily the Titan feature called dual-faced ports is exactly what we need. This permits mapping of messages from a northern interface(UpperTester messages) to a southern interface (UDP).
In our case UDP has the following set of messages:
type port UDPasp_PT message
{
inout ASP_UDP;
inout ASP_UDP_message;
out ASP_UDP_open;
out ASP_UDP_close;
in ASP_UDP_open_result;
} with { extension "provider" }
So the outwards UtInitialize message will have to be mapped to an ASP_UDP_message (we will assume the port is used in advanced mode, see documentation). Incoming ASP_UDP_message will have to be decoded into an UtInitializeResult; (the _open,_close, _open_result messages we can neglect for the time being) .
And this is how this can be done:
group portDefinitions {
/**
* @desc Upper Tester port
*/
type port UpperTesterPort message {
out
UtInitialize;
in
UtInitializeResult;
} with { extension "user UDPasp_PT
out (
UtInitialize -> ASP_UDP_message: function(enc_UtInitialize);
)
in(
ASP_UDP_message -> UtInitializeResult: function(dec_UtInitializeResult_message)
)"
} // end UpperTesterPort
} // end portDefinitions
When UtInitialize is received on the northern interface , a function enc_UtInitilaize is called.
this function looks something like this:
//------------------------------------------------------------------------------
function enc_UtInitialize (in UtInitialize par_utinit) return ASP_UDP_message
//------------------------------------------------------------------------------
{
var PDU_UtPrimitives v_PDU_UtPrimitives;
v_PDU_UtPrimitives.primitive.utInitialize := par_utinit;
v_PDU_UtPrimitives.messageType := '00'O;
var ASP_UDP_message v_udp_msg;
v_udp_msg.data := f_enc_PDU_UtPrimitives(v_PDU_UtPrimitives);
v_udp_msg.remote_addr := tsp_udp_remote_addr;
v_udp_msg.remote_port := tsp_udp_remote_port;
v_udp_msg.id := omit;
return v_udp_msg;
} with { extension "prototype(convert)" }
It's input is a UtInitialize and it's output is an ASP_UDP_message which will be sent by the UDP port.
In the receiving direction a function dec_UtInitializeResult will be used:
//-----------------------------------------------------------------------------
function dec_UtInitializeResult (in ASP_UDP par_msg, out UtInitializeResult v_UtInitializeResult) return integer
//------------------------------------------------------------------------------
{
var PDU_UtPrimitives v_PDU_UtPrimitives := f_dec_PDU_UtPrimitives(par_msg.data);
v_UtInitializeResult := v_PDU_UtPrimitives.primitive.utInitializeResult;
if (v_PDU_UtPrimitives.messageType == '01'O) {
return 0;
} else {
return 1;
}
} with { extension "prototype(backtrack)" }
and so on.
More details can be found in the reference guide 4.22.1 Dual faced ports
and in the examples I have posted in this forum.
https://www.eclipse.org/forums/index.php/t/1072614/
https://www.eclipse.org/forums/index.php/t/1068184/
https://www.eclipse.org/forums/index.php/t/1068359/
For other ports, we will have to examine case by case;
If the protocol is not transported over TCP-UDP-SCTP/IP/ETH but som other stack , we will have to find some appropriate replacement.
Best regards
Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1717376 is a reply to message #1717372] |
Sat, 12 December 2015 11:27 |
|
Hi Muhammad,
your PATH variable should contain the path to Titan binaries
C:\cygwin64\home\titan\Install\bin
and you should also have a variable LD_LIBRARY_PATH which points to C:\cygwin64\home\titan\Install\lib
Please check these video tutorials that were created not by us but by another user, they explain thoroughly installation and usage on Cygwin:
https://www.youtube.com/watch?v=6CKxOhZt7Gg
https://www.youtube.com/watch?v=hso34ReEiP8
Please also re-generate your Makefile to contain the switch -U type; when using this, Titan will split the generated files for types in several pieces, so it should compile more quickly. Don't expect miracles though, it will still take hours.
Linux is more efficient in using memory as you can imagine; any mainstream flavor, Ubuntu, SuSe, RedHat will do. It's also easier to setup Titan on Linux, you only need to set the three environmental variables TTCN3_DIR, PATH, LD_LIBRARY_PATH and nothing else.
You may also want to check Murli Sharma's post:
https://www.eclipse.org/forums/index.php/t/1072021/
he is doing something similar and we already managed to solve his similar problems.
Best regards
Elemer
|
|
| |
Re: Default as Omit not working in TTCN 3 test cases [message #1717562 is a reply to message #1717560] |
Mon, 14 December 2015 20:09 |
|
Hi Muhammad,
Titan cannot find the crypto libraries of openssl which are needed for instance for big integer handling;
$(EXECUTABLE): $(OBJECTS)
if $(CXX) $(LDFLAGS) -o $@ $(OBJECTS) \
-L$(TTCN3_DIR)/lib -l$(TTCN3_LIB) \
-L$(OPENSSL_DIR)/lib -lcrypto \
-L$(XMLDIR)/lib $($(PLATFORM)_LIBS); \
then : ; else $(TTCN3_DIR)/bin/titanver $(OBJECTS); exit 1; fi
from your logfile it can be seen that this is executed as:
-L/home/uzah/TTCN3/lib -lttcn3 \
-L/home/uzah/TTCN3/lib -lcrypto \
-L/home/uzah/TTCN3/lib -lxml2 -lpthread -lrt; \
so OPENSSL_DIR and XML_DIR are all set to /home/uzah/TTCN3 which is wrong.
The fault is caused by this line :
-L$(OPENSSL_DIR)/lib -lcrypto \
Simplest thing you can do is add the following line to Makefile
OPENSSL_DIR = /usr
# Your platform: (SOLARIS, SOLARIS8, LINUX, FREEBSD or WIN32)
PLATFORM = LINUX
If your OpenSSL is installed , it's probably in /usr
and see if it works;
If it does not , pls find where your openSSL is installed and enter the right value.
Similarly, if you want to use XML, you will have to add the correct XML_DIR.
If you install Titan from a pre-built binary then in the installation instructions it is explained how these libraries have to be installed and these variables set; if you build for yourself from source code, these settings are to be present in Makefile.personal, see README.linux
Pls let me know if this helped
Best regards
Elemer
|
|
| | | |
Goto Forum:
Current Time: Sun Apr 28 21:28:31 GMT 2024
Powered by FUDForum. Page generated in 0.08139 seconds
|