Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » Translation ports vs dual-faced ports part3 (SNMP/IPL4 in UDP mode)
Translation ports vs dual-faced ports part3 [message #1764120] Thu, 25 May 2017 08:47
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 760
Registered: January 2015
Senior Member
Dear all,

I felt I needed to include the IPL4 test port in this series, for multiple reasons:
-first of all, its; API' although this maight not be apparent, it's different from the other test ports' API
-secondly, it's a versatile port, presumably used in may applications

The basis for this exercise is an earlier post:

Dual-faced IPL4 test port in UDP mode(Another SNMP over UDP example)
https://www.eclipse.org/forums/index.php/t/1072614/

The code is functionally equivalent with our first example in the series:
The SNMP layer sends SNMP v1, v2, v3 messages to the upper end of the translation port which
emits UDP messages on the lower end , respectively the exact opposite.



Here's the declaration of the translation port:



type port SNMP_IPL4_PT message map to IPL4asp_PT //Translation port
{
 out 
     SNMPv1_Message to ASP_Send with f_enc_SNMPv1_TranslationPort(),
     SNMPv2_Message to ASP_Send with f_enc_SNMPv2_TranslationPort(),
     SNMPv3_Message to ASP_Send with f_enc_SNMPv3_TranslationPort()     
 in      
     SNMPv1_Message from ASP_RecvFrom with f_dec_SNMPv1_TranslationPort(),
     SNMPv2_Message from ASP_RecvFrom with f_dec_SNMPv2_TranslationPort(),
     SNMPv3_Message from ASP_RecvFrom with f_dec_SNMPv3_TranslationPort(),
     ASP_Event          
}
 

versus the declaration of the dual face port:


type port SNMP_IPL4_PT message  //DualFace port
{
 out 
     SNMPv1_Message,
     SNMPv2_Message,
     SNMPv3_Message       
 in      
     SNMPv1_Message,
     SNMPv2_Message,
     SNMPv3_Message,
     ASP_Event          
}with 
{ extension 
   "user IPL4asp_PT
      out(
        SNMPv1_Message -> ASP_Send: function(f_enc_SNMPv1_DualFace);
        SNMPv2_Message -> ASP_Send: function(f_enc_SNMPv2_DualFace);
        SNMPv3_Message -> ASP_Send: function(f_enc_SNMPv3_DualFace)	
    )    
      in(
        ASP_RecvFrom -> SNMPv1_Message : function(f_dec_SNMPv1_DualFace),
	                SNMPv2_Message : function(f_dec_SNMPv2_DualFace),
	                SNMPv3_Message : function(f_dec_SNMPv3_DualFace);
        ASP_Event -> ASP_Event : simple
    )
   " 
}


a function after:

function f_enc_SNMPv1_TranslationPort
( in SNMPv1_Message pl_in,
  out ASP_Send pl_out) //return integer
{
  pl_out.connId := -1;
  pl_out.msg := enc_SNMPv1_Message(pl_in);         
  pl_out.proto := omit; 
  
  port.setstate(0);
}with {extension "prototype(fast)" } 




and before:

function f_enc_SNMPv1_DualFace
( in SNMPv1_Message pl_in,
  out ASP_Send pl_out) return integer
{
  pl_out.connId := -1;
  pl_out.msg := enc_SNMPv1_Message(pl_in);         
  pl_out.proto := omit; 
  
  return 0;
}with {extension "prototype(backtrack)" }



A log snippet demonstrating the workings of the code:


06:27:02.487306 USER SNMP_Test.ttcn:71 { errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
06:27:02.487485 PORTEVENT SNMP_Test.ttcn:195 Sent on IPL4_PCO_Translation to system @SNMPmsg-Types.SNMPv1-Message : { version := 0, community := '7075626C6963'O ("public"), data := { get_request := { request_id := 5, error_status := 1, error_index := 1, variable_bindings := { } } } }
06:27:02.487543 PORTEVENT SNMP_Test.ttcn:195 The state of the IPL4_PCO_Translation port was changed by a setstate operation to unset. Information: by test environment.
06:27:02.487589 DEBUG SNMP_IPL4_Definitions.ttcn:45 enc_SNMPv1_Message(): Encoding @SNMPmsg-Types.SNMPv1-Message: { version := 0, community := '7075626C6963'O ("public"), data := { get_request := { request_id := 5, error_status := 1, error_index := 1, variable_bindings := { } } } }
06:27:02.487926 DEBUG SNMP_IPL4_Definitions.ttcn:45 enc_SNMPv1_Message(): Stream after encoding: '301802010004067075626C6963A00B0201050201010201013000'O
06:27:02.488010 PORTEVENT SNMP_IPL4_Definitions.ttcn:48 The state of the IPL4_PCO_Translation port was changed by a setstate operation to translated.
06:27:02.488068 PORTEVENT SNMP_Test.ttcn:195 Outgoing message was mapped to @IPL4asp_Types.ASP_Send : { connId := -1, proto := omit, msg := '301802010004067075626C6963A00B0201050201010201013000'O }
06:27:02.488293 TIMEROP SNMP_Test.ttcn:196 Start timer T: 5 s
06:27:02.489379 PORTEVENT SNMP_Test.ttcn:197 Message enqueued on IPL4_PCO_Translation from system @IPL4asp_Types.ASP_RecvFrom : { connId := 1, remName := "127.0.0.1", remPort := 25000, locName := "127.0.0.1", locPort := 35000, proto := { udp := { } }, userData := 0, msg := '301802010004067075626C6963A00B0201050201010201013000'O } id 1
06:27:02.489456 PORTEVENT SNMP_Test.ttcn:197 The state of the IPL4_PCO_Translation port was changed by a setstate operation to unset. Information: by test environment.
06:27:02.489637 DEBUG SNMP_IPL4_Definitions.ttcn:91 dec_SNMPv1_Message(): Stream before decoding: '301802010004067075626C6963A00B0201050201010201013000'O
06:27:02.489985 DEBUG SNMP_IPL4_Definitions.ttcn:91 dec_SNMPv1_Message(): Decoded @SNMPmsg-Types.SNMPv1-Message: { version := 0, community := '7075626C6963'O ("public"), data := { get_request := { request_id := 5, error_status := 1, error_index := 1, variable_bindings := { } } } }
06:27:02.490084 PORTEVENT SNMP_IPL4_Definitions.ttcn:93 The state of the IPL4_PCO_Translation port was changed by a setstate operation to translated.
06:27:02.490143 PORTEVENT SNMP_Test.ttcn:197 Incoming message was mapped to @SNMPmsg-Types.SNMPv1-Message : { version := 0, community := '7075626C6963'O ("public"), data := { get_request := { request_id := 5, error_status := 1, error_index := 1, variable_bindings := { } } } } id 1
06:27:02.490216 MATCHING SNMP_Test.ttcn:199 Matching on port IPL4_PCO_Translation succeeded:  matched
06:27:02.490288 PORTEVENT SNMP_Test.ttcn:199 Receive operation on port IPL4_PCO_Translation succeeded, message from system(): @SNMPmsg-Types.SNMPv1-Message : { version := 0, community := '7075626C6963'O ("public"), data := { get_request := { request_id := 5, error_status := 1, error_index := 1, variable_bindings := { } } } } id 1
06:27:02.490338 PORTEVENT SNMP_Test.ttcn:199 Message with id 1 was extracted from the queue of IPL4_PCO_Translation.
06:27:02.490382 VERDICTOP SNMP_Test.ttcn:200 setverdict(pass): none -> pass 



As before, port skeletons of the "virtual" SNMP port have to be added to the build.

 SNMP_IPL4_PT.cc
 SNMP_IPL4_PT.hh



A particularity of IPL4 is that

 IPL4asp_User_CtrlFunct.ttcn 
 IPL4asp_User_CtrlFuncDef.cc


have to be adapted as explained in the IPL4 documentation:


"The demo directory contains the following template files:

• IPL4asp_User_CtrlFunct.ttcn
Replace the <user port type> tag with your user port type and the <user types module>
tag with the module name in which the user port type is declared.
• IPL4asp_User_CtrlFunctDef.cc
Replace the <user port type> tag with your user port type and the <user types module>
tag with the module name in which the user port type is declared. Remember to replace the underscores in the TTCN name with double underscore!
Note that depending on the module in which the control functions are declared, their use may be ambiguous without qualifying the module.
E.g. if the default functions shipped with the port should be used in a user module in which also
another user port type is defined, use the IPL4asp_Types module name as follows:
	IPL4asp_Types.f_IPL4_listen



Alternatively, one may apply names here depending on their special naming conventions.

Note: In demo directory a script file can be found, called: generate_control_functs.sh.
This script file can be used to automatically generate the files IPL4asp_User_CtrlFunct.ttcn and IPL4asp_User_CtrlFunctDef.cc and
replaces the tags described above. The script should be put in the same
directory with IPL4asp_PortType.ttcn and IPL4asp_PT.cc because it generates the files from these."


I hope all this will prove useful for you

As usual, code and logs are attached.


Best regards

Elemer
Previous Topic:Translation ports vs dual-faced ports part2
Next Topic:Synchronization between independent events
Goto Forum:
  


Current Time: Sun Jun 24 01:59:24 GMT 2018

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

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

Back to the top