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 09:27  |
Eclipse User |
|
|
|
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 332 times)
|
|
| | | | | | |
Re: Example of SNMP over UDP [message #1717838 is a reply to message #1717832] |
Thu, 17 December 2015 04:05   |
Eclipse User |
|
|
|
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
|
|
| | | | | | | | |
Goto Forum:
Current Time: Mon Jul 07 10:00:54 EDT 2025
Powered by FUDForum. Page generated in 0.09977 seconds
|