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 3(SCTP, IPL4asp, SCTP client, NCAT, test port, transport layer, IP layer 4, MTU, SCTP fragmentation)
SCTP support in Eclipse Titan part 3 [message #1822397] Thu, 05 March 2020 16:19
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Dear all,

We'll continue our SCTP posts with an SCTP client implementation based on the IPL4asp test port.

The IPL4asp port enables user access to the services of transport layers of the IP stack present in the operating system; as such , it was
intended to be the Swiss Army knife of all things IP transport, supporting TCP, TCP with TLS, UDP, UDP with DTLS, SCTP, SCTP with DTLS, and more,
all this over both IPv4 and IPv6. Again, services, hence performance and limitations are originated in the stack implementations that already
reside in the executing OS. In quite a number of IP-related projects one can get away by using only the IPL4 as test port for a multitude of user
applications (especially if the translation capability, discussed earlier in several posts, is considered); this comes with a certain complexity
though that assumes a degree of familiarity with the product.

The source code, documentation etc. of the port can be downloaded from
https://github.com/eclipse/titan.TestPorts.IPL4asp

It has a product dependency of
https://github.com/eclipse/titan.TestPorts.Common_Components.Socket-API
(Socket_API_Definitions.ttcn) that should not be ignored.

The source code attached in a compacted format was created with 'make archive' and contains the source code of both the above products
plus specific code (SCTP.ttcn), config file, logs and Makefile. Execution was done on a Ubuntu 18.04 machine.

On the server side, there is no difference when compared with the client implementation discussed in the previous post:


ncat -l --sctp -vv -p 5202
Ncat: Version 7.31 ( https://nmap.org/ncat )
Ncat: Listening on :::5202
Ncat: Listening on 0.0.0.0:5202
Ncat: Connection from 127.0.0.1.
Ncat: Connection from 127.0.0.1:58849.
0  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
1  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
2  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
3  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
4  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
5  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
6  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
7  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
8  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
9  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ
Client waiting for 1 second
Client sending close
NCAT DEBUG: Closing connection.


On the TTCN-3 client side, after mapping the port, a CONNECT is called:

//******************************************************
function f_preamble() runs on SCTP_CT  system System_CT
//******************************************************
{

 
  vl_result := c_res;

  vl_result := f_IPL4_connect( SCTP_PCO, tsp_hostname, tsp_remPort,"",0, -1, {sctp := {  
sinfo_stream:=omit,
sinfo_ppid:=omit,
remSocks:=omit,
assocId:=omit
  
  } }, {} ); 

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

  v_cid:=vl_result.connId; 

  
}



Interesting to note here is that when needed, SCTP can fragment user messages to ensure that the SCTP packet passed to the lower layer
conforms to the path MTU. On receipt, fragments are reassembled into complete messages before being passed to the SCTP user
(see the related optional config parameter sctp_path_mtu_size).

This from Titan perspective means that no message length calculation function -as used in the case of TCP - is necessary to correctly extract user
messages from the transport layer.



An altstep, activated as default behaviour, has the role to deal with the events sent from the transport layer to the user:
:

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

} 


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

//Connect
f_preamble();

//Send some payload
:
:

f_postamble();
deactivate(v_def); 
unmap(self:SCTP_PCO, system:SCTP_PCO);

  all component.kill;
}

:



User messages are simulated with some dummy payload, as before:

//******************************************************
testcase tc_sctp0() runs on SCTP_CT   {
//******************************************************
:
//Send some payload
for (var integer i:=0;i<=9;i:=i+1)  { 
var charstring vl_s:=int2str(i)&"  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ"&"\n\r";

SCTP_PCO.send(t_ASP_Send(v_cid,vl_s)) ;  
}
 
SCTP_PCO.send(t_ASP_Send(v_cid,"Client waiting for 1 second"&"\n\r")) ; 
 
 t0.start;
 t0.timeout;

SCTP_PCO.send(t_ASP_Send(v_cid,"Client sending close"&"\n\r")) ;
  
:
}



The above can followed up in the execution log:

:
16:37:49.636534 SCTP.ttcn:95 Port SCTP_PCO was started.
16:37:49.636597 SCTP.ttcn:95 Component type SCTP.SCTP_CT was initialized.
16:37:49.636644 SCTP.ttcn:98 Altstep as_SCTP_Event was activated as default, id 1
16:37:49.636691 SCTP.ttcn:99 Mapping port mtc:SCTP_PCO to system:SCTP_PCO.
16:37:49.636927 SCTP.ttcn:99 SCTP_PCO: IPL4asp__PT_PROVIDER::set_parameter: enter (name: debug, value: Yes)
16:37:49.636985 SCTP.ttcn:99 SCTP_PCO: IPL4asp__PT_PROVIDER::set_parameter: enter (name: sinit_num_ostreams, value: 10)
16:37:49.637034 SCTP.ttcn:99 SCTP_PCO: IPL4asp__PT_PROVIDER::set_parameter: enter (name: sinit_max_instreams, value: 10)
16:37:49.637080 SCTP.ttcn:99 SCTP_PCO: IPL4asp__PT_PROVIDER::set_parameter: enter (name: sinit_max_attempts, value: 0)
16:37:49.637125 SCTP.ttcn:99 SCTP_PCO: IPL4asp__PT_PROVIDER::set_parameter: enter (name: sinit_max_init_timeo, value: 0)
16:37:49.637170 SCTP.ttcn:99 SCTP_PCO: IPL4asp__PT_PROVIDER::user_map(SCTP_PCO): enter
16:37:49.637214 SCTP.ttcn:99 Port SCTP_PCO was mapped to system:SCTP_PCO.
16:37:49.637326 SCTP.ttcn:99 Map operation of mtc:SCTP_PCO to system:SCTP_PCO finished.
16:37:49.637413 SCTP.ttcn:60 entering f__IPL4__PROVIDER__connect: :0 -> 127.0.0.1:5202 / SCTP
16:37:49.637462 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: enter
16:37:49.637512 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: create new socket: :0 -> 127.0.0.1:5202
16:37:49.637558 SCTP.ttcn:60 SCTP_PCO: SetLocalSockAddr: locName:  loc_port 0 def_loc_host 0.0.0.0, add_family AF_INET
16:37:49.637602 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: use default host: 0.0.0.0:0
16:37:49.637691 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::setOptions: enter, number of options: 0
16:37:49.637740 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::setOptions: sock: 6
16:37:49.637788 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::setOptions: Socket option REUSEADDR on socket 6 is set to: 1
16:37:49.637832 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::setOptions: Setting sctp options sinit_num_ostreams:10,sinit_max_instreams:10, sinit_max_attempts:0, sinit_max_init_timeo:0
16:37:49.637884 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::setOptions: leave
16:37:49.637937 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: sock: 6
16:37:49.638170 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER: ConnAdd enter: type: 4, ssl_tls_type: 0, sock: 6, parentIx: -1
16:37:49.638262 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnAdd: new sockListSize: 16
16:37:49.638330 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnAdd: connId: 1
16:37:49.638396 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnAdd: connId: set ssl options for connId : 1
16:37:49.638447 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::set_ssl_supp_option: set SSL options
16:37:49.638521 SCTP.ttcn:60 SCTP_PCO: IPL4asp__PT_PROVIDER::ConnAdd: leave: sockListCnt: 1
16:37:49.638570 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: EAGAIN: waiting in poll: fd 6   connId: 1
16:37:49.638617 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: EAGAIN: poll returned: 1
16:37:49.638660 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: EAGAIN: revents: 0x0005
16:37:49.638703 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: EAGAIN: writable
16:37:49.638748 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: Probing connection, result: sucessfull
16:37:49.638790 SCTP.ttcn:60 SCTP_PCO: f__IPL4__PROVIDER__connect: leave
16:37:49.638873 SCTP.ttcn:60 SCTP_PCO: f_IPL4_connect result: { errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
16:37:49.638936 SCTP.ttcn:68 connect result{ errorCode := omit, connId := 1, os_error_code := omit, os_error_text := omit }
16:37:49.639079 SCTP.ttcn:108 Sent on SCTP_PCO to system @IPL4asp_Types.ASP_Send : { connId := 1, proto := omit, msg := '3020203A41414242434344454546464747484849494A4A4B4B4C4C4D4D4E4E4F4F5050515152525353545456565757585859595A5A0A0D'O ("0  :AABBCCDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTVVWWXXYYZZ\n\r") }

:
:

16:37:49.644078 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: enter, fd: 6
16:37:49.644163 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: connId: 1 READABLE   sock: 6, type: 4, sslState: 0
16:37:49.644211 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: sctp message received
16:37:49.644254 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: sctp peername and sockname obtained
16:37:49.644307 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: Notification received
16:37:49.644350 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::handle_event: incoming SCTP_ASSOC_CHANGE event.
16:37:49.644416 SCTP.ttcn:114 Message enqueued on SCTP_PCO from system @Socket_API_Definitions.PortEvent : { sctpEvent := { sctpAssocChange := { clientId := 1, proto := { sctp := { sinfo_stream := omit, sinfo_ppid := omit, remSocks := omit, assocId := omit } }, sac_state := SCTP_COMM_UP (0) } } } id 1
16:37:49.644478 SCTP.ttcn:114 SCTP_PCO: IPL4asp__PT_PROVIDER::Handle_Fd_Event_Readable: leave
16:37:49.644528 SCTP.ttcn:46 Matching on port SCTP_PCO succeeded:  matched
16:37:49.644598 SCTP.ttcn:46 Receive operation on port SCTP_PCO succeeded, message from system(): @Socket_API_Definitions.PortEvent : { sctpEvent := { sctpAssocChange := { clientId := 1, proto := { sctp := { sinfo_stream := omit, sinfo_ppid := omit, remSocks := omit, assocId := omit } }, sac_state := SCTP_COMM_UP (0) } } } id 1
16:37:49.644650 SCTP.ttcn:46 Message with id 1 was extracted from the queue of SCTP_PCO.
16:37:49.644695 SCTP.ttcn:114 Default with id 1 (altstep as_SCTP_Event) has reached a break statement. Skipping current alt statement or receiving operation.
16:37:50.644825 SCTP.ttcn:114 Timeout t0: 1 s
16:37:50.645025 SCTP.ttcn:116 Sent on SCTP_PCO to system @IPL4asp_Types.ASP_Send : { connId := 1, proto := omit, msg := '436C69656E742073656E64696E6720636C6F73650A0D'O ("Client sending close\n\r") }
:




The configuration file used:

[LOGGING]
#LogFile := "MyExample.log"
FileMask := LOG_ALL | TTCN_ERROR | TTCN_USER | MATCHING | TTCN_DEBUG 
#|LOG_ALL | TTCN_WARNING | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_PORTEVENT
ConsoleMask := TTCN_ERROR | TTCN_USER 
#| TTCN_PORTEVENT
LogSourceInfo := Yes



[MODULE_PARAMETERS]

SCTP.tsp_hostname:="127.0.0.1" 
SCTP.tsp_remPort:=5202 

[TESTPORT_PARAMETERS]
system.SCTP_PCO.debug := "Yes"
system.SCTP_PCO.sinit_num_ostreams := "10"
system.SCTP_PCO.sinit_max_instreams := "10"
system.SCTP_PCO.sinit_max_attempts := "0"
system.SCTP_PCO.sinit_max_init_timeo := "0"


[MAIN_CONTROLLER]
TCPPort := 8035
KillTimer := 1.0


[EXECUTE]
SCTP.control


I hope this post will offer some pointers to those who encountered problems when using IPL4 in SCTP mode.
Next we'll implement an SCTP server in TTCN-3 with Titan.


Best regards
Elemer
Previous Topic:ctags for TTCN-3 / vim?
Next Topic:Eclipse Titan 6.6.1 release announcement
Goto Forum:
  


Current Time: Sun Jun 13 06:39:38 GMT 2021

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

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

Back to the top