|
Re: Help needed on Structure UDP Example [message #1772805 is a reply to message #1772756] |
Fri, 15 September 2017 13:39 |
|
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 14:41 |
Philip Weber Messages: 6 Registered: June 2017 |
Junior Member |
|
|
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 #1772812 is a reply to message #1772808] |
Fri, 15 September 2017 15:03 |
|
Hi Philip,
I'm not sure you are using the Makefile as intended:
you can generate the Makefile with:
makefilegen ...options ...list of TTCN files...list of cc/hh files ...list of c/h files
e.g.
makefilegen -s file1.ttcn file2cc file3.hh file4.c file5.h
(for options see makefilegen -h)
then the generated Makefile can be used with
which should build the executable
BTW I think something is missing in your post, I see no Linux error.
P.S, There's an older post that might be useful:
https://www.eclipse.org/forums/index.php/t/1068004/
BR
Elemer
|
|
|
Re: Help needed on Structure UDP Example [message #1772823 is a reply to message #1772812] |
Fri, 15 September 2017 18:26 |
Philip Weber Messages: 6 Registered: June 2017 |
Junior Member |
|
|
Hey Elemer,
Okay I guess I have to explain more in detail what I want to do. My self created UDP "server" is in a different folder and should also start in a different console as the titan executable. So the "server.c" has its own makefile. I just want to start the server first and after that the titan executable, so I can see in both consoles how they are communicating.
I attached my working example with sending an integer. A integer value is send to the UDP "server". After that it is squared and send back.
Now I want to create the same example again, but with sending a structure instead of an integer. So I guess at some point I have to encode the struct (in the PCOType::outgoing_send method?). After that I have to decode it somehow in my "server.c" file (can't use the decode function because of this supported platform error) and send another encoded structure back.
Maybe I'm doing something wrong. I am very new to ttcn3 and titan.
[Updated on: Fri, 15 September 2017 18:27] Report message to a moderator
|
|
|
Re: Help needed on Structure UDP Example [message #1772835 is a reply to message #1772823] |
Sat, 16 September 2017 06:34 |
|
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 #1772850 is a reply to message #1772849] |
Sun, 17 September 2017 15:14 |
|
Hi Philip,
1)you need a final with {encode "RAW"} at the end of the module
2) pt.receive(ASP_UDP_message:*) -> value v_ASP_UDP_message
should be changed to
pt.receive(ASP_UDP_message:?) -> value v_ASP_UDP_message
and then it compiles (see attached)
BR
Elemer
|
|
|
|
Re: Help needed on Structure UDP Example [message #1772864 is a reply to message #1772858] |
Mon, 18 September 2017 05:39 |
|
Hi Philip,
from the error message it is apparent that the error occurs when a Request Structure is decoded ( not a Response Structure);
in lack of a log , I only suspect that teh problem is here:
alt {
// Handle the case when the expected answer comes in
[] pt.receive(ASP_UDP_message:?) -> value v_ASP_UDP_message {
log(f_decode_RequestStructure(v_ASP_UDP_message.data))
var ResponseStructure respStruct := f_decode_ResponseStructure(v_ASP_UDP_message.data)
setverdict(pass);
log("Expected message from server was received");
replyTimer.stop;
}
log(f_decode_RequestStructure(v_ASP_UDP_message.data)) <----------------------
var ResponseStructure respStruct := f_decode_ResponseStructure(v_ASP_UDP_message.data)
On the client side you should encode Requests and decode Responses, never the opposite.
v_ASP_UDP_message.data contains a Response and you are trying to decode it as a Request.
BR
Elemer
|
|
|
|
Powered by
FUDForum. Page generated in 0.04608 seconds