Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » SCTP support in Eclipse Titan part 4(SCTP, IPL4asp, NCAT, netcat, test port, SCTP server)
SCTP support in Eclipse Titan part 4 [message #1822731] Thu, 12 March 2020 10:43
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1063
Registered: January 2015
Senior Member
Dear all,

let's quickly summarize what we have done in the previous posts:

-we have implemented an SCTP client behaviour in TTCN-3, using SCTPasp or IPL4asp test ports
-the SCTP protocol terminated in an SCTP server mocked with netcat
-user protocol was simulated with some dummy characterstring messages (as these messages were short, SCTP fragmentation was not looked into)

In this post we will reverse the roles and implement server behaviour with TTCN-3, to which server a netcat SCTP client will build an associaton
After compilation (make) and start of execution (ttcn3_start ./SCTP ./SCTP.cfg),
instead of CONNECT, a LISTEN ASP is sent to the SCTP stack:

 :
 vl_result := f_IPL4_listen( SCTP_PCO, "127.0.0.1", tsp_localPort, 
 { sctp := {  
sinfo_stream:=omit,
sinfo_ppid:=omit,
remSocks:=omit,
assocId:=omit 
  } },
{} 
);
: 


This is acknowledged with a LISTEN result:
:
11:06:17.735684 SCTP.ttcn:47 SCTP_PCO: f__IPL4__PROVIDER__listen: leave: socket created, connection ID: 1, fd: 6
11:06:17.735727 SCTP.ttcn:47 SCTP_PCO: f_IPL4_listen result: { errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
11:06:17.735776 SCTP.ttcn:55 listen  result{ errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
:



Events are caught by an altstep activated as default behaviour:

//******************************************************
altstep  as_SCTP_Event()  runs on SCTP_CT   {
//Will be used as default behaviour!!!!
//******************************************************
    []SCTP_PCO.receive(ASP_Event:?)      {repeat};

} 






The SCTP server will start and wait for incoming connections:


//******************************************************
testcase tc_sctp0() runs on SCTP_CT   {
//******************************************************
  timer t0:=1.0;
  var ASP_RecvFrom v_rcv  
  var default v_def := activate(as_SCTP_Event()); 
  map(self:SCTP_PCO, system:SCTP_PCO);

//listen
f_preamble();

//receive some payload
  
  alt {
  
  []SCTP_PCO.receive(ASP_RecvFrom:?) -> value v_rcv {  
  
  if(v_rcv.msg==char2oct("secret\n")) {}  //stop server
  else   {repeat}
  }
  }
  
  
f_postamble();
deactivate(v_def); 
unmap(self:SCTP_PCO, system:SCTP_PCO);

  all component.kill;
}




:
11:06:29.916083 SCTP.ttcn:92 Message enqueued on SCTP_PCO from system @Socket_API_Definitions.PortEvent : { connOpened := { connId := 2, remName := "127.0.0.1", remPort := 59010, locName := "127.0.0.1", locPort := 5202, proto := { sctp := { sinfo_stream := omit, sinfo_ppid := omit, remSocks := omit, assocId := omit } }, userData := 0 } } id 1
11:06:29.916133 SCTP.ttcn:92 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: leave
11:06:29.916173 SCTP.ttcn:94 Matching on port SCTP_PCO failed: Type of the first message in the queue is not @IPL4asp_Types.ASP_RecvFrom.
11:06:29.916211 SCTP.ttcn:33 Matching on port SCTP_PCO succeeded:  matched
11:06:29.916275 SCTP.ttcn:33 Receive operation on port SCTP_PCO succeeded, message from system(): @Socket_API_Definitions.PortEvent : { connOpened := { connId := 2, remName := "127.0.0.1", remPort := 59010, locName := "127.0.0.1", locPort := 5202, proto := { sctp := { sinfo_stream := omit, sinfo_ppid := omit, remSocks := omit, assocId := omit } }, userData := 0 } } id 1
11:06:29.916324 SCTP.ttcn:33 Message with id 1 was extracted from the queue of SCTP_PCO.
11:06:29.916360 SCTP.ttcn:94 Default with id 1 (altstep as_SCTP_Event) has reached a break statement. Skipping current alt statement or receiving operation.
:


This connection (well, association is the right word) is established when the ncat client is directed to the server;
whatever is typed into the terminal, terminated by ENTER, will be displayed in the Titan logs:

ncat --sctp localhost 5202 
éLDHÉFHéHÉFÉNVVAF              #type something and press ENTER
SKKKSKKSLLÉÉÉkkkkdkkdkdk       #type something and press ENTER  
secret                         #type "secret" and press ENTER


If codeword "secret" [ENTER] is sent, the server is shut down.

:
11:06:41.689295 SCTP.ttcn:94 Receive operation on port SCTP_PCO succeeded, message from system(): @IPL4asp_Types.ASP_RecvFrom : { connId := 2, 
remName := "127.0.0.1", remPort := 59010, locName := "127.0.0.1", locPort := 5202, proto := { sctp := { sinfo_stream := 0, sinfo_ppid := 0, 
remSocks := omit, assocId := omit } }, userData := 0, msg := '7365637265740A'O ("secret\n") } id 6
11:06:41.689357 SCTP.ttcn:94 Message with id 6 was extracted from the queue of SCTP_PCO.
11:06:41.689401 SCTP.ttcn:73 SCTP_PCO: f__IPL4__close:  proto { unspecified := { } } connId 1
11:06:41.689445 SCTP.ttcn:73 SCTP_PCO: f__IPL4__PROVIDER__close: enter: connId: 1
11:06:41.689486 SCTP.ttcn:73 SCTP_PCO: IPL4asp__PT_PROVIDER::getAndCheckSockType: sock type is: 3
11:06:41.689541 SCTP.ttcn:73 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnDel: enter: connId: 1
11:06:41.689582 SCTP.ttcn:73 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnDel: fd: 6
11:06:41.689665 SCTP.ttcn:73 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnFree: enter: connId: 1
11:06:41.689713 SCTP.ttcn:73 SCTP_PCO: f__IPL4__close result: { errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
11:06:41.689762 SCTP.ttcn:74 close result{ errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
:




The server side code in TTCN-3:

module SCTP
{

// SCTP client:  ncat --sctp localhost 5202 

import from IPL4asp_Types all;
import from IPL4asp_PortType all;
import from Socket_API_Definitions all;

modulepar {
 
  integer    tsp_localPort:=5202 ;
}

type component SCTP_CT {
  var IPL4asp_Types.Result  c_res:= { errorCode := omit, connId  := omit, os_error_code:=omit, os_error_text:= omit }; 
  var IPL4asp_Types.Result  vl_result;  
  var integer v_cid, v_ret;
  port IPL4asp_PT        SCTP_PCO; 
}

type component System_CT
{
   port IPL4asp_PT SCTP_PCO;
}
//******************************************************
altstep  as_SCTP_Event()  runs on SCTP_CT   {
//Will be used as default behaviour!!!!
//******************************************************
    []SCTP_PCO.receive(ASP_Event:?)      {repeat};

} 

//******************************************************
function f_preamble() runs on SCTP_CT  system System_CT
//******************************************************
{
  vl_result := c_res;

  vl_result := f_IPL4_listen( SCTP_PCO, "127.0.0.1", tsp_localPort, {sctp := {  
sinfo_stream:=omit,
sinfo_ppid:=omit,
remSocks:=omit,
assocId:=omit 
  } }, {} ); 

  log("listen  result",vl_result);
  if (not(ispresent(vl_result.connId)))
  {
    log("Could not listen to SCTP");
    stop;
  } 

  v_cid:=vl_result.connId;   
}

//******************************************************
function f_postamble() runs on SCTP_CT  system System_CT
//******************************************************
{
//close  SCTP association

  vl_result :=  f_IPL4_close(SCTP_PCO, v_cid)
  log("close result",vl_result); 
}


//******************************************************
testcase tc_sctp0() runs on SCTP_CT   {
//******************************************************
  timer t0:=1.0;
  var ASP_RecvFrom v_rcv  
  var default v_def := activate(as_SCTP_Event()); 
  map(self:SCTP_PCO, system:SCTP_PCO);

//listen
f_preamble();

//receive some payload
  
  alt {
  
  []SCTP_PCO.receive(ASP_RecvFrom:?) -> value v_rcv {  
  
  if(v_rcv.msg==char2oct("secret\n")) {}  //stop server
  else   {repeat}
  }
  }
  
  
f_postamble();
deactivate(v_def); 
unmap(self:SCTP_PCO, system:SCTP_PCO);

  all component.kill;
}

//******************************************************
control
//******************************************************

{
  execute( tc_sctp0());
}//endcontrol

}//endmodule



OS deployed was Ubuntu 18.04, all files attached in a downloadable archive.

The code of IPL4asp
https://github.com/eclipse/titan.TestPorts.IPL4asp
and its dependency
https://github.com/eclipse/titan.TestPorts.Common_Components.Socket-API
were used.

Next, we'll look into SCTP protocol modules, protocol emulations and protocol daemons.

Best regards
Elemer

Previous Topic:Support of JSON module
Next Topic:Eclipse Titan product structure part 1
Goto Forum:
  


Current Time: Sat Jul 11 06:15:59 GMT 2020

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

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

Back to the top