Home » Eclipse Projects » Eclipse Titan » Example of SNMP over UDP(Example of SNMP over UDP with ASN.1 and dual-faced test port)
Example of SNMP over UDP [message #1700830] |
Tue, 07 July 2015 13:27 |
|
This example is of SNMP messages sent and received over UDP. SNMP is a protocol that has been specified in ASN.1 and correspondingly , the messages are encoded in binary using BER encoding.
BER is a standard , non-configurable, robust binary encoding used in a large number of telecom protocols in conjunction with ASN.1.
It's worth mentioning here that Titan, besides being a TTCN-3 compiler, it includes a fully-featured ASN.1 compiler as well.
Titan generates codec functions automatically based on their declaration; in our case codec functions are declared in SNMP_Functions.ttcn:
external function enc_SNMPv1_Message(in SNMPv1_Message pdu) return octetstring
with { extension "prototype(convert) encode(BER:BER_ENCODE_DER)" };
If needed, these declarations of external functions can be terminated in actual external functions written in C++,
making it easy to replace the internal codecs with external ones.
As SNMP messages are sent over UDP, it makes sense to use the UDP test port for this purpose.
the UDP test port (and some other Titan test ports as well) can be used in two modes:
basic and advanced. Basic means that the configuration is read at start from the configuration file and it is
valid until execution terminates; this also means that the configuration cannot be changed dynamically.
If dynamic reconfiguration is desired, the port can be used in advanced mode, when the reconfiguration can be obtained by messages sent to the port.
In this example (SNMP_Test.ttcn) both basic and advanced modes are used (see the port documentation for details):
the main test component (MTC) uses a UDP test port in advanced mode to send SNMP messages to a PTC connected in basic mode which simply echoes back the messages.
*.UDP_PCO.debugging := "yes"
*.UDP_PCO.localPort := "35000"
*.UDP_PCO.mode := "basic"
*.UDP_PCO_DF.debugging := "yes"
*.UDP_PCO_DF.mode := "advanced"
An interesting problem can be observed here: we have a protocol layer with a set of (SNMP) messages that has to be sent to a port that accepts a different set of (UDP) messages.
there are several solutions to this:
-first of all, a thin TTCN-3 layer can be used to encode the SNMP messages, assemble the UDP and send it to the port in one direction, receive UDP, extract the payload and decode it and send it to the upper layer;
an example to this effect can be seen in the demo of the DNS protocol module , see https://github.com/eclipse/titan.ProtocolModules.DNS
-secondly , encoding etc. can be done on the fly as in the example in SNMP_Test.ttcn
UDP_PCO_DF.send(t_ASP_UDP_message(enc_SNMPv3_Message(valueof(t_snmpv3_msgExtS('ABCD'O,c_get_request_pdu({})))),v_connId))
In the receiving direction things are not that simple as this disables matching on the protocol messages, so the payload has to be first extracted and decoded
-last but not least , the test port can be used in dual-faced mode (again supported by most Titan test ports) which means that it can be told to turn a protocol-shaped face to the upper layer:
SNMP_Test2.ttcn and SNMP_UDP_Definitions.ttcn exemplify this:
type port SNMP_UDP_PT message //DualFace port
{
out
SNMPv1_Message,
SNMPv2_Message,
SNMPv3_Message,
ASP_UDP_open,
ASP_UDP_close
in
SNMPv1_Message,
SNMPv2_Message,
SNMPv3_Message,
ASP_UDP_open_result
}with
{ extension
"user UDPasp_PT
out(
SNMPv1_Message -> ASP_UDP_message: function(f_enc_SNMPv1_DualFace);
SNMPv2_Message -> ASP_UDP_message: function(f_enc_SNMPv2_DualFace);
SNMPv3_Message -> ASP_UDP_message: function(f_enc_SNMPv3_DualFace);
ASP_UDP_open -> ASP_UDP_open : simple;
ASP_UDP_close -> ASP_UDP_close : simple
)
in(
ASP_UDP_message -> SNMPv1_Message : function(f_dec_SNMPv1_DualFace),
SNMPv2_Message : function(f_dec_SNMPv2_DualFace),
SNMPv3_Message : function(f_dec_SNMPv3_DualFace);
ASP_UDP -> - : discard;
ASP_UDP_open_result -> ASP_UDP_open_result : simple
)
"
}
Translation functions can be declared to implement mapping between the upper face and the lower face. Details about this can be found in the Titan referenceguide.
To use the attached code, please extract it to a directory named SNMP, followed by :
cd SNMP/bin
../install.script
make
ttcn3_start ./SNMP SNMP.cfg
The ttcn3_start script can be used to start multi-component configurations.
Please check the generated log files for details.
The Makefile was created with :
makefilegen -g -e SNMP *.asn *.ttcn *.cc *.hh
Best regards
Elemer
-
Attachment: SNMP.tgz
(Size: 285.56KB, Downloaded 317 times)
|
|
| |
Re: Example of SNMP over UDP [message #1717728 is a reply to message #1717714] |
Wed, 16 December 2015 10:59 |
|
Hi Muhammad,
you are using Eclipse, but it's the config file reference is not set properly, so Eclipse can't read it and assumes a default temporary config file instead , which does not contain pertinent test port data(some default related to logging etc.)
This is visible from the following line:
Using configuration file: temporal_804564873184683452_XXXXX.cfg
Here you should see SNMP.cfg referenced instead of the temp config file.
If you run from command line:
ttcn3_start ./SNMP SNMP.cfg
it should execute as expected. (assuming envrionment variables are set properly)
For how to configure Eclipse please check this post:
https://www.eclipse.org/forums/index.php/t/1072811/
towards the end it is explained how to set the config file path and how to execute.
Pls. let me know if this helped
BR
Elemer
|
|
|
Re: Example of SNMP over UDP [message #1717752 is a reply to message #1717728] |
Wed, 16 December 2015 13:52 |
Muhammad Uzair Messages: 35 Registered: November 2015 |
Member |
|
|
Hi Elemer,
I was running with all the components suggested in your post with the exception of titan plugin which was "TITAN_Designer_and_Executor_plugin-5.3.pl1-opensource_1.zip".
Now I have done a fresh install with 5.4 plugin, but there is another issue:
After building the project, I select Run As --> Titan Parallel launcher, following console is printed
out of dynamic memory in yy_get_next_buffer()
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2 *
* Version: CRL 113 200/5 R4B *
* Copyright (c) 2000-2015 Ericsson Telecom AB *
* All rights reserved. This program and the accompanying materials *
* are made available under the terms of the Eclipse Public License v1.0 *
* which accompanies this distribution, and is available at *
* http://www.eclipse.org/legal/epl-v10.html *
*************************************************************************
Using configuration file:
Titan execution controller shows that project is terminated (see the attached image)
After that I have reverted to 5.3 plugin and the result is same as previous.
Regarding command line execution, I am getting the following error:
/bin/sh: line 4: C:cygwin64hometitanInstall/bin/titanver: No such file or directory
Although all of the environmental variables are set:
uzah@PK-LHR-DT-UZAH /home/eclipse
$ echo $TTCN3_DIR
C:\cygwin64\home\titan\Install
uzah@PK-LHR-DT-UZAH /home/eclipse
$ echo $LD_LIBRARY_PATH/
/home/titan/Install/lib/
uzah@PK-LHR-DT-UZAH /home/eclipse
$ echo $MANPATH
C:\cygwin64\home\titan\Install\man
uzah@PK-LHR-DT-UZAH /home/eclipse
$ echo $PATH
/usr/local/bin:/usr/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/u-blox/depot/3.1:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/90/Tools/binn:/cygdrive/c/Program Files (x86)/Anite/Shared Components:/cygdrive/c/Program Files/Anite/Shared Components:/cygdrive/c/Program Files (x86)/Anite/LogViewer:/cygdrive/c/Program Files (x86)/Anite/LogViewer/ALV2:/usr/bin:/home/titan/Install/bin:/cygdrive/c/Program Files/Perforce:/cygdrive/c/Program Files (x86)/Skype/Phone:/home/titan/Install:/home/titan/install/lib:/home/titan/install/bin
Best Regards,
Muhammad Uzair
[Updated on: Wed, 16 December 2015 14:29] Report message to a moderator
|
|
|
Re: Example of SNMP over UDP [message #1717760 is a reply to message #1717752] |
Wed, 16 December 2015 14:41 |
|
Hi Muhammad,
one thing that maybe is not sufficiently emphasized in our documentation:
-to run Eclipse from within Cygwin is not recommended ;
I suspect you have installed and started Eclipse from Cygwin which is a kind of virtual environment with memory limitations;
If you must use this kind of setup, install Eclipse in Windows and configure it so it can see the Cygwin directory system. Eclipse then has to be started in Windows.
Please read the installation documentation and/or watch the youtube videos I have recommended.
Eclipse is very much memory hungry so what happened is that when started it immediately run out of memory.
For your project with ASN.1 RRC files I would recommend Linux anyhow; Cygwin is not the best way to utilize memory.
So either you use Eclipse in Windows and Titan core in Cygwin, but preferably you should use Linux.
Best regards
Elemer
|
|
|
Re: Example of SNMP over UDP [message #1717763 is a reply to message #1717760] |
Wed, 16 December 2015 14:58 |
|
Hi Muhammad, one more thing:
- did you manage to build and execute from command line at least one complete project?
In other words: did you have a stable and working compilation environment on command line?
Please try to establish the command line environment first and move to Eclipse only when that one is working and you fully understand it;
Eclipse plug-ins are useful but they introduce a layer of complexity that can be confusing in teh beginning.
So my recommendation is you start with Linux and command -line , no Eclipse first.
Best regards
Elemer
|
|
| |
Re: Example of SNMP over UDP [message #1717838 is a reply to message #1717832] |
Thu, 17 December 2015 09:05 |
|
Hi Muhammad,
I apologize for the problems you are encountering; unfortunately our documentation might not be complete in every respect ;
as we used this tool only internally so far , and everyone had the possibility to take a training where the basics were explained, we have scaled our documentation
to that.
The Titan compiler/executor and the plug-ins both have their own prerequisites. Most of the compiler/executor prerequisites are present on mainstream Linux distributions; if not hey have to be installed separately.
The installation guides should give you an idea about what prerequisites are assumed.
In your case it appears that flex might be missing ( for what flex is see http://aquamentus.com/flex_bison.html) .
Please check if this is true and if yes, install flex (and bison if appropriate).
As for your memory problem, in case of Cygwin it's not only the amount of physical memory , but also how much is allocated to Cygwin (see https://cygwin.com/cygwin-ug-net/setup-maxmem.html).
It's very difficult to diagnose your problems remotely; each environment may have its own quirks, some of which we have never seen before.
This is one of the reasons I recommend Linux over Cygwin, as Cygwin is the quirkiest of them all.
From the forum I see that lots of people experimenting with Titan managed to overcome their initial problems, so please do not despair.
We'll also try to help as much as we can.
Best regad
Elemer
|
|
| | | |
Re: Example of SNMP over UDP [message #1720110 is a reply to message #1720102] |
Thu, 14 January 2016 13:29 |
|
Hi Muhammad,
I follow you now on Twitter so you can send me personal messages.
First we have to make sure it executes and compiles on command line. Eclipse tends to use a lot of memory so apparently you are running out of memory when using Eclipse.
Let's put Eclipse aside and execute from command line.
The log you have sent me is the console log, but there should be a more detailed log file generated by Titan , with file extension .log.
Pls. attach that one.
From the console log it appears that the test case is executed, but details are not in the console log (as they are not supposed not be )
Best regards
Elemer
|
|
| | |
Re: Example of SNMP over UDP [message #1720117 is a reply to message #1720112] |
Thu, 14 January 2016 14:48 |
|
Hi Muhammad,
great,
there are three command line tools which can be used to process the log files: logformat, logmerge and logfilter.
Logformat makes the files more readable ( a sort of pretty-printing); logmerge will merge files from multiple components so one can follow parallel execution, and logfilter as it can be guessed filters the log file.
Please check them at your convenience.
Best regards
Elemer
|
|
| |
Goto Forum:
Current Time: Fri Jan 03 02:06:04 GMT 2025
Powered by FUDForum. Page generated in 0.03515 seconds
|