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 part2 (ICMP/IP/Ethernet )
Translation ports vs dual-faced ports part2 [message #1763623] Thu, 18 May 2017 06:44
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 807
Registered: January 2015
Senior Member
Dear all,

this time we will resuscitate the example of dual-face port usage published earlier in:

Example of ping (ICMP) over a layer 2 test port with Titan

(Example of ICMP/IP over a LANL2 test port in dual-faced mode with Titan)
https://www.eclipse.org/forums/index.php/t/1068359/

in the form of a translation port use case.

The code presents interest in itself as it describes a modality to directly access the Ethernet layer using the LANL2asp tets port.

The northern part of the translation port (IcmpPort) receives ICMP messages like this:

template PDU_ICMP t_PDU_ICMP_ECho(OCT2 par_seq):=

{

  echo:={

    type_field:=8,
    code:=0,
    checksum:='0000'O,
    identifier:='0002'O,
    sequence_number:=par_seq,
    data:='6162636465666768696a6b6c6d6e6f7071727374757677616263646566676869'O


  }

} 

and translates them to Ethernet frames for the southern end (LANL2asp port).
The test case sends a cycle of ICMP messages (pings) and receives the ICMP echo sent by the kernel IP stack.

Here's the translation port:


//Translation port

type port IcmpPort message map to LANL2asp_PT{
  in PDU_ICMP from ASP_v2_LANL2 with dec_ASP_v2_LANL2_Icmp();
  out PDU_ICMP to ASP_LANL2 with enc_PDU_ICMP();
  in Bool3, Bool4;

  in ASP_LANL2_Error, ASP_LANL2_open_result, ASP_v2_LANL2_Error, ASP_LANL2;
} 
 


versus the dual-faced port, somewhat more complicated and difficult to read:

//Dual faced port
type port IcmpPort message {
  inout PDU_ICMP;
  in Bool3, Bool4;
} 



with 
{ 

  extension "user LANL2asp_PT
  out(                
  PDU_ICMP    -> ASP_LANL2: function(enc_PDU_ICMP)
  )
  in(

  ASP_LANL2                   -> PDU_ICMP : function(dec_ASP_LANL2_Icmp),
  										- : discard;
  ASP_LANL2_Error             -> 		- : discard;
  ASP_v2_LANL2                -> PDU_ICMP : function(dec_ASP_v2_LANL2_Icmp),
  										- : discard;
  ASP_LANL2_open_result       -> 		- : discard;
  ASP_v2_LANL2_Error          -> 		- : discard
  )"

}
  

and one of the functions after :

//------------------------------------------------------------------------------
function dec_ASP_LANL2_Icmp (in ASP_LANL2 par_msg, out PDU_ICMP result )   //return integer
//------------------------------------------------------------------------------

{
  var PDU_ICMP v_PDU_ICMP;

  var IPv4_packet v_IPv4_packet:=  f_IPv4_dec(par_msg.payload);

  if (v_IPv4_packet.header.proto ==1)//ICMP
  {
    v_PDU_ICMP:=  f_dec_PDU_ICMP(v_IPv4_packet.payload)
    result:=v_PDU_ICMP;
    log("ICMP received!!")
    port.setstate(0);
    return;
  }

  port.setstate(1);

}
with { extension "prototype(fast)" }




and before (not much difference here):


//------------------------------------------------------------------------------
function dec_ASP_LANL2_Icmp (in ASP_LANL2 par_msg, out PDU_ICMP result )   return integer
//------------------------------------------------------------------------------

{
  var PDU_ICMP v_PDU_ICMP;

  var IPv4_packet v_IPv4_packet:=  f_IPv4_dec(par_msg.payload);

  if (v_IPv4_packet.header.proto ==1)//ICMP
  {
    v_PDU_ICMP:=  f_dec_PDU_ICMP(v_IPv4_packet.payload)
    result:=v_PDU_ICMP;
    log("ICMP received!!")
    return 0;
  }

  return -1;

}
with { extension "prototype(backtrack)" } 




Here's a snippet from the log where the message flow can be followed:

2017/May/09 03:05:56.183850 PORTEVENT ICMP2ETH.ttcn:250 Sent on Icmp_PCO to system @ICMP_Types.PDU_ICMP : { echo := { type_field := 8, code := 0, checksum := '0000'O, identifier := '0002'O, sequence_number := '00C9'O, data := '6162636465666768696A6B6C6D6E6F7071727374757677616263646566676869'O ("abcdefghijklmnopqrstuvwabcdefghi") } }
2017/May/09 03:05:56.183884 PORTEVENT ICMP2ETH.ttcn:250 The state of the Icmp_PCO port was changed by a setstate operation to unset. Information: by test environment.
2017/May/09 03:05:56.183902 DEBUG ICMP2ETH.ttcn:156 Encoding PDU_ICMP: { echo := { type_field := 8, code := 0, checksum := '0000'O, identifier := '0002'O, sequence_number := '00C9'O, data := '6162636465666768696A6B6C6D6E6F7071727374757677616263646566676869'O ("abcdefghijklmnopqrstuvwabcdefghi") } }
2017/May/09 03:05:56.184042 DEBUG ICMP2ETH.ttcn:156 PDU_ICMP after encoding: '08004C91000200C96162636465666768696A6B6C6D6E6F7071727374757677616263646566676869'O
2017/May/09 03:05:56.184128 DEBUG ICMP2ETH.ttcn:165 Entering f__IPv4__enc__eth
2017/May/09 03:05:56.184193 DEBUG ICMP2ETH.ttcn:165 Encoding IPv4_packet: { header := { ver := 4, hlen := 5, tos := 0, tlen := 10, id := 50000, res := '0'B, dfrag := '0'B, mfrag := '0'B, foffset := 0, ttl := 128, proto := 1, cksum := 0, srcaddr := '7F000001'O, dstaddr := '7F000001'O }, ext_headers := omit, payload := '08004C91000200C96162636465666768696A6B6C6D6E6F7071727374757677616263646566676869'O }
2017/May/09 03:05:56.184285 DEBUG ICMP2ETH.ttcn:165 Entering Encode_IPv4_extension_headers
2017/May/09 03:05:56.184358 DEBUG ICMP2ETH.ttcn:165 Entering Encode_IPv4_ESP_tails
2017/May/09 03:05:56.184424 DEBUG ICMP2ETH.ttcn:167 Entering f__IPv4__checksum
2017/May/09 03:05:56.184487 DEBUG ICMP2ETH.ttcn:167 Entering Calculate_cksum
2017/May/09 03:05:56.184552 PORTEVENT ICMP2ETH.ttcn:177 The state of the Icmp_PCO port was changed by a setstate operation to translated.
2017/May/09 03:05:56.184575 PORTEVENT ICMP2ETH.ttcn:250 Outgoing message was mapped to @LANL2asp_Types.ASP_LANL2 : { eth_dst_addr := 'FFFFFFFFFFFF'O, eth_src_addr := '000C29FBE6D1'O, type_field := '0800'O, payload := '4500003CC35000008001796E7F0000017F00000108004C91000200C96162636465666768696A6B6C6D6E6F7071727374757677616263646566676869'O }
2017/May/09 03:05:56.184695 TIMEROP ICMP2ETH.ttcn:251 Start timer t_time: 4 s
2017/May/09 03:05:56.194215 PORTEVENT ICMP2ETH.ttcn:252 Message enqueued on Icmp_PCO from system @LANL2asp_Types.ASP_LANL2 : { eth_dst_addr := 'FFFFFFFFFFFF'O, eth_src_addr := '005056E0346F'O, type_field := '0806'O, payload := '0001080006040001005056E0346FC0A88B020000000000007F000001000000000000000000000000000000000000'O } id 1
2017/May/09 03:05:56.194285 MATCHING ICMP2ETH.ttcn:254 Matching on port Icmp_PCO succeeded.
2017/May/09 03:05:56.194301 PORTEVENT ICMP2ETH.ttcn:254 Receive operation on port Icmp_PCO succeeded, message from system(): @LANL2asp_Types.ASP_LANL2: { eth_dst_addr := 'FFFFFFFFFFFF'O, eth_src_addr := '005056E0346F'O, type_field := '0806'O, payload := '0001080006040001005056E0346FC0A88B020000000000007F000001000000000000000000000000000000000000'O } id 1
2017/May/09 03:05:56.194316 PORTEVENT ICMP2ETH.ttcn:254 Message with id 1 was extracted from the queue of Icmp_PCO.
2017/May/09 03:05:57.194147 PORTEVENT ICMP2ETH.ttcn:252 Message enqueued on Icmp_PCO from system @LANL2asp_Types.ASP_LANL2 : { eth_dst_addr := 'FFFFFFFFFFFF'O, eth_src_addr := '005056E0346F'O, type_field := '0806'O, payload := '0001080006040001005056E0346FC0A88B020000000000007F000001000000000000000000000000000000000000'O } id 2
2017/May/09 03:05:57.194231 MATCHING ICMP2ETH.ttcn:254 Matching on port Icmp_PCO succeeded.
2017/May/09 03:05:57.194249 PORTEVENT ICMP2ETH.ttcn:254 Receive operation on port Icmp_PCO succeeded, message from system(): @LANL2asp_Types.ASP_LANL2: { eth_dst_addr := 'FFFFFFFFFFFF'O, eth_src_addr := '005056E0346F'O, type_field := '0806'O, payload := '0001080006040001005056E0346FC0A88B020000000000007F000001000000000000000000000000000000000000'O } id 2
2017/May/09 03:05:57.194266 PORTEVENT ICMP2ETH.ttcn:254 Message with id 2 was extracted from the queue of Icmp_PCO.  


The files

icmpPort.cc
icmpPort.hh


are parts of the port skeleton generated and added to the build for the reasons explained in the previous part.

Code archive and log attached.

Best regards

Elemer

Previous Topic:Using Titan as a fuzzing engine part 3
Next Topic:Translation ports vs dual-faced ports part3
Goto Forum:
  


Current Time: Wed Sep 19 21:04:32 GMT 2018

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

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

Back to the top