Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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 243 times)
Re: Example of SNMP over UDP [message #1717714 is a reply to message #1700830] Wed, 16 December 2015 09:41 Go to previous messageGo to next message
Muhammad Uzair is currently offline Muhammad UzairFriend
Messages: 35
Registered: November 2015
Member
Hi Elemer,

I was trying to run this example on windows but I am getting an error when executing test cases. The error is:

The maximum number of open file descriptors (256) is greater than FD_SETSIZE (64). Ensure that Test Ports using Install_Handler do not try to wait for events of file descriptors with values greater than FD_SETSIZE (64). (Current caller of Install_Handler is "UDP_PCO")

Can you please help me in identifying the error?
I have attached the build log, executor log and archived project.

I am getting a similar error while running UDP examplehttps://www.eclipse.org/forums/index.php/t/1068004/


Thanks and Best Regards,
Muhammad Uzair
Re: Example of SNMP over UDP [message #1717728 is a reply to message #1717714] Wed, 16 December 2015 10:59 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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 Go to previous messageGo to next message
Muhammad Uzair is currently offline Muhammad UzairFriend
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 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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 #1717832 is a reply to message #1717763] Thu, 17 December 2015 07:32 Go to previous messageGo to next message
Muhammad Uzair is currently offline Muhammad UzairFriend
Messages: 35
Registered: November 2015
Member
Hi Elemer,

Thanks a lot for your valuable feedback. Let me answer your questions one by one.
1-The "out of dynamic memory in yy_get_next_buffer()" error comes even if I start eclipse from windows. I think the issue is not related to RAM availability as i am utilizing less than 10% of 16GB.
2-I am not able to build any project on windows using CLI, although I have followed every step told by videos and your posts.
3-I have setup titan on centos 6.5 and I am able to compile the code there. After that I setup eclipse on linux by following the steps mentioned by you. Execution failed there too, here is the log
input in flex scanner failed
*************************************************************************
* TTCN-3 Test Executor - Main Controller 2                              *
* Version: CRL 113 200/5 R4A                                            *
* 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: 

I haven't tried installing 5.3 plugin on linux yet. Will do that and update this post

PS: Right now I am using the example projects to make some demo for the tool.

Best Regards,
Muhammad Uzair
Re: Example of SNMP over UDP [message #1717838 is a reply to message #1717832] Thu, 17 December 2015 09:05 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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 #1717845 is a reply to message #1717838] Thu, 17 December 2015 10:24 Go to previous messageGo to next message
Muhammad Uzair is currently offline Muhammad UzairFriend
Messages: 35
Registered: November 2015
Member
Hi ELemer,

I totally understand that and is very thankful for the support. I will try that your suggestions and will get back to you.

Thanks,
Muhammad Uzair
Re: Example of SNMP over UDP [message #1717846 is a reply to message #1717845] Thu, 17 December 2015 10:28 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Muhammad,

one more thing:

if it is feasible , you can give me remote access to the Linux machine and I can try to install Titan;

If this is OK with you , PM me on twitter and we can discuss the details:

https://twitter.com/jrama00


Best regards
Elemer

Re: Example of SNMP over UDP [message #1720102 is a reply to message #1717846] Thu, 14 January 2016 12:37 Go to previous messageGo to next message
Muhammad Uzair is currently offline Muhammad UzairFriend
Messages: 35
Registered: November 2015
Member
Hi Elemer,

I have done fresh setup on redhat 7 and setup team viewer to access it remotely. Is team viewer ok for you? if so tell me where to send details. I tried using twitter but it doesn't let you send a personal message to a person who is not following you. My twitter id is "mm_uzair"

I have also attached the log for this example compilation and execution. Its not throwing any error in command line execution, but no test case is executed either.
On eclipse setup, It compiles with similar log but prints following when using RunAs -> Titan Parallel Launcher
out of dynamic memory in yy_get_next_buffer()

*************************************************************************
* TTCN-3 Test Executor - Main Controller 2                              *
* Version: CRL 113 200/5 R4A                                            *
* 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: 


Similar results were obtained using cetos7
Best Regards,
Muhammad Uzair
  • Attachment: SNMP.log
    (Size: 5.55KB, Downloaded 105 times)

[Updated on: Thu, 14 January 2016 12:48]

Report message to a moderator

Re: Example of SNMP over UDP [message #1720110 is a reply to message #1720102] Thu, 14 January 2016 13:29 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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 #1720111 is a reply to message #1720110] Thu, 14 January 2016 13:31 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
BTW,

it's simple to use ttcn3_start to start execution, as indicated:


cd SNMP/bin
../install.script 
make

ttcn3_start ./SNMP  SNMP.cfg   



BR Elemer
Re: Example of SNMP over UDP [message #1720112 is a reply to message #1720111] Thu, 14 January 2016 13:47 Go to previous messageGo to next message
Muhammad Uzair is currently offline Muhammad UzairFriend
Messages: 35
Registered: November 2015
Member
Hi Elemer,

Thanks a lot for your quick help. I have attached all three log files generated by titan.

Best Regards,
Muhammad Uzair
Re: Example of SNMP over UDP [message #1720117 is a reply to message #1720112] Thu, 14 January 2016 14:48 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
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

Re: Example of SNMP over UDP [message #1720253 is a reply to message #1720117] Fri, 15 January 2016 15:07 Go to previous message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Muhammad,

I have attached a real eclipse.ini
to help you with the Eclipse configuration.

BR Elemer
  • Attachment: eclipse.ini
    (Size: 0.49KB, Downloaded 113 times)
Previous Topic:Eclipse Titan 5.4.0 receives release approval
Next Topic:Error Compiling TTCN-3 Script
Goto Forum:
  


Current Time: Thu Jun 17 16:46:51 GMT 2021

Powered by FUDForum. Page generated in 0.02280 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top