Help needed on Structure UDP Example [message #1772756] |
Thu, 14 September 2017 15:25  |
Eclipse User |
|
|
|
Hey Guys,
I need to create some examples with TTCN3 and Titan. I already created some samples sending an integer or string to an udp server and receiving something again. Now I want to do the same with a structure but I encounter some problems.
In my udp server I have to "decode" the received message. So I included "StructUdpExample.hh" to use the decode and encode function but I can't even compile it. I get the following message: Titan/include/version.h:78:4 error: #error "No supported platform has been defined in the Makefile. The supported ones: SOLARIS, SOLARIS8, LINUX, WIN32"
I created an makefile and set the platform to Linux. What am I doing wrong?
And how exactly should I encode and decode the structure I want to send? Should I do this in the PCOType.cc file?
Thats what I already succesfully did. Just sending and receiving a string.
........... ---------------------String--------------------------->
TTCN3........................................................................UDP Server
............<--------------------String----------------------------
And thats what I want to do now. Sending and receiving a structure.
..................----------Struct(string, int, float)-------------->
TTCN3............................................................................UDP Server
..................<---------Struct(int, string)----------------------
Would be really great if someone could help me. I am very new to TTCN3 and Titan. I attached my project.
Best regards
|
|
|
Re: Help needed on Structure UDP Example [message #1772805 is a reply to message #1772756] |
Fri, 15 September 2017 09:39   |
Eclipse User |
|
|
|
Hi Philip,
welcome to TTCN-3 and Titan.
A few generic observations:
-it's great you write your own test port, I don't want to discourage you , but please be aware that for UDP you can use the
legacy UDP test port :
https://github.com/eclipse/titan.TestPorts.UDPasp
or the IPL4 test port in UDP mode (this is maybe somewhat more complex, so maybe you should wait with this...):
https://github.com/eclipse/titan.TestPorts.IPL4asp
-I see that you use Titan 5 R5A which is probably OK for a this project, but 6 R2A is already available.
-in your Makefile you should specify your platform as below:
# Your platform: (SOLARIS, SOLARIS8, LINUX, FREEBSD or WIN32)
PLATFORM = LINUX
WIN32 is for Cygwin/MinGW; Linux is the recommended platform
-when one sends complex messages between systems then the rules converting these structures to a binary form (which will be sent on the "wire" ) have to be established; the other end will have to use the same rules to reassemble the sent structures.
for this you can use your proprietary encoding/decoding functions which will take abstract structures as input and result in a binary output in one direction, and take binary and result in structures in the other direction;
you can also use the RAW codec which is built into Titan; please search this forum for "RAW" ; i have published a few posts about it;
The use of RAW is convenient as one can control the encoding with instructions embedded in TTCN-3 code. Based on these instructions Titan will generate the appropriate codecs.
The typical flow is that the codec function is called for the structured variable/template ; the binary output is then fed to the test port as UDP payload.
For the opposite direction the UDP port delivers the payload which is the decode by the appropriate function.
You can call these codecs from the port directly as well, but that will transform the port from a UDP port to a message specific port.
I hope this will give you some pointers to start with
Best regards
Elemer
|
|
|
Re: Help needed on Structure UDP Example [message #1772808 is a reply to message #1772805] |
Fri, 15 September 2017 10:41   |
Eclipse User |
|
|
|
Hey Elemer,
First of all, thanks for your fast reply! This sample is for learning purposes at university. So it should be as simple and minimalistic as possible. So I guess I will stick to the self created test port because the students are already used to that. But I will definitely have a look in the legacy UDP test port for personal use, thanks!
I am trying to include the "StructUdpExample.hh" file to my server.c to get access to the encode and decode function but than I receive this Linux error. I already set the platform to Linux. Here is the makefile for my UDP port:
# Your platform: (SOLARIS, SOLARIS8, LINUX, FREEBSD or WIN32)
PLATFORM = LINUX
# Your C++ compiler:
# (if you change the platform, you may need to change the compiler)
CXX = g++
# Flags for the C++ preprocessor (and makedepend as well):
CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)/include
# Flags for the C++ compiler:
CXXFLAGS = -Wall
ifeq ($(PLATFORM), WIN32)
# Silence linker warnings.
LDFLAGS += -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc
endif
compile:
g++ -o server server.c ../StructUdpExample.cc -I/home/philip/Titan/include
|
|
|
|
|
Re: Help needed on Structure UDP Example [message #1772835 is a reply to message #1772823] |
Sat, 16 September 2017 02:34   |
Eclipse User |
|
|
|
Hi Philip,
your test port , although uses UDP as transport , it's not a generic UDP port, but a port which accepts integers:
type port PCOType message
{
inout integer;
}
A generic UDP port should accept octetstring , which is a different name for binary.
This octetstring can hold any kind of information, even structures, but they have to go through encoding first.
The other end will receive the binary and using the same rules, can decode the contained info.
Pls take a look into the code of the UDP port I have indicated.
I have modified your code to include an example of RAW encoding/decoding:
module IntegerUdpExample
{
type port PCOType message
{
inout integer;
}
type component MTCType
{
port PCOType MyPCO;
}
external function f_encode_Structure(in Structure pdu) return octetstring
with { extension "prototype(convert) encode(RAW)" }
external function f_decode_Structure(in octetstring data) return Structure
with { extension "prototype(convert) decode(RAW)" }
type integer UInt16 (0 .. 65535) with { variant "FIELDLENGTH(16),BYTEORDER(last)" };
type charstring CSL6 with { variant "FIELDLENGTH(6)" };
type record Structure
{
CSL6 f1,
UInt16 f2,
float f3
}
with {variant "" }
testcase TC_encdec() runs on MTCType system MTCType
{
var Structure v_struct:={f1:="abcd",f2:=666, f3:=3.14}
log(f_encode_Structure(v_struct))
log(f_decode_Structure(f_encode_Structure(v_struct)))
}
control
{
//execute(Square(2, 4));
execute(TC_encdec())
}
}with { encode "RAW" }
Best regards
Elemer
|
|
|
|
|
|
|
Re: Help needed on Structure UDP Example [message #1772930 is a reply to message #1772864] |
Mon, 18 September 2017 16:31  |
Eclipse User |
|
|
|
Hey Elemer,
Of course you're right. I just forgot to delete this log line. Everything is working now! Thank you very much for your solid and fast help!
I modified the code so the client and server are checking the received structures now. I attached the project so it can help someone with similar problems in future!
|
|
|
Powered by
FUDForum. Page generated in 0.06974 seconds