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 2(SCTP, ASP, PDU, SCTPasp, SCTP client, NCAT, test port, normal mode)
SCTP support in Eclipse Titan part 2 [message #1822187] Sat, 29 February 2020 08:00
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Dear all,

let's continue with the SCTPasp port used in normal mode.

But before that, let's examine a bit the
Titan test port taxonomy
Our attentive users may have observed already that Titan has two categories of test ports,
one named XXXasp and one XXXmsg, where XXX is the name of a protocol, e.g SCTPasp, HTTPmsg etc.
So where this "asp" or "msg" suffix is coming from? What does it signify?

According to the ISO OSI layer model, adjacent protocol layers in a stack communicate using ASPs, Abstract Service Primitives,
which encapsulate PDUs, Protocol Data Units, which PDUs are pieces of information used by protocol layers to
communicate with the same protocol layer in peer stacks.

So test ports with suffix "asp" permit the TTCN-3 code to access and control protocol layers via appropriate ASPs, this code
personifying the role of a user of the service provided by the protocol layer. These ASPs, whenever relevant, will contain the pertinent PDUs,
typically in a binary format. For instance:

type octetstring PDU_SCTP;

type record ASP_SCTP
{
  integer client_id optional,
  integer sinfo_stream,
  integer sinfo_ppid,
  PDU_SCTP data
}


In some cases though to simplify things we want to send protocol messages directly,
and avoid the complication of assembling ASP structures, encode and encapsulate the PDUs etc.
In this case we can use the message, or "msg" suffixed ports, which will accept
protocol messages adressed to the remote user layer. Why not suffix these ports as "pdu" though?
PDU refers to the encoded, binary form of the messages, while the ports accept messages in a more convenient structured format.

SCTPasp in normal mode
Last we looked into using the SCTP port in single mode; in this post we'll examine its usage in the so called
normal mode. There are advantages and disadvantages tied to each mode:
-single mode results in a simpler, more standard code, but with a static configuration originating in the configuration file that is read at the
start of execution only
-in normal mode, the capability of dynamically re-configuring the port during execution can be taken advantage of, but this comes
at the expense of a more complex TTCN-3 code, which deviates from the language standard. hence rendering the resulting code less portable across
tools
(BTW this remark is valid for all test ports in the Titan ecosystem, not only SCTPasp)

In our new example, after sending CONNECT, socket options are set by ASPs ( and not by the config file, as in our previous example):

SCTP_PCO.send(vl_connect) ;
  t0.start;
  alt 
  {
    []SCTP_PCO.receive(ASP_SCTP_RESULT:?) -> value vl_result { v_sctp_client_id:=vl_result.client_id } ;
    []t0.timeout { }
  }

SCTP_PCO.send(t_ASP_SCTP_INIT) ;
  t0.start;
  alt 
  {    
    []SCTP_PCO.receive(ASP_SCTP_RESULT:?)  { } ;
    []t0.timeout { }
  } 

SCTP_PCO.send(t_ASP_SCTP_EVENTS) ;
  t0.start;
  alt 
  {   
    []SCTP_PCO.receive(ASP_SCTP_RESULT:?)  { } ;
    []t0.timeout { }
  }



These will be acknowledged by appropriate RESULT ASPs:

08:34:21.412473 SCTP.ttcn:95 Mapping port mtc:SCTP_PCO to system:SCTP_PCO.
08:34:21.412661 SCTP.ttcn:95 SCTPasp Test Port (SCTP_PCO): Calling user_map(SCTP_PCO).
08:34:21.412732 SCTP.ttcn:95 SCTPasp Test Port (SCTP_PCO): Running in NORMAL MODE.
08:34:21.412756 SCTP.ttcn:95 SCTPasp Test Port (SCTP_PCO): Leaving user_map().
08:34:21.412777 SCTP.ttcn:95 Port SCTP_PCO was mapped to system:SCTP_PCO.
08:34:21.412844 SCTP.ttcn:95 Map operation of mtc:SCTP_PCO to system:SCTP_PCO finished.
08:34:21.412888 SCTP.ttcn:105 Sent on SCTP_PCO to system @SCTPasp_Types.ASP_SCTP_Connect : { peer_hostname := "127.0.0.1", peer_portnumber := 5202 }
08:34:21.412919 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Calling outgoing_send (ASP_SCTP_CONNECT).
08:34:21.412941 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Creating SCTP socket.
08:34:21.412975 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Setting SCTP socket options (initmsg).
08:34:21.413000 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Setting SCTP socket options (events).
08:34:21.413038 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Connecting to (127.0.0.1):(5202)
08:34:21.413169 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Connection in progress to (127.0.0.1):(5202)
08:34:21.413197 SCTP.ttcn:105 SCTPasp Test Port (SCTP_PCO): Leaving outgoing_send (ASP_SCTP_CONNECT).
08:34:21.413218 SCTP.ttcn:106 Start timer t0: 1 s
08:34:21.413266 SCTP.ttcn:107 Message enqueued on SCTP_PCO from system @SCTPasp_Types.ASP_SCTP_RESULT : { client_id := 6, error_status := false, error_message := omit } id 1
08:34:21.413298 SCTP.ttcn:107 SCTPasp Test Port (SCTP_PCO): Connection successfully established to (127.0.0.1):(5202)
08:34:21.413323 SCTP.ttcn:109 Matching on port SCTP_PCO succeeded:  matched
08:34:21.413357 SCTP.ttcn:109 Receive operation on port SCTP_PCO succeeded, message from system(): @SCTPasp_Types.ASP_SCTP_RESULT : { client_id := 6, error_status := false, error_message := omit } id 1
08:34:21.413381 SCTP.ttcn:109 Message with id 1 was extracted from the queue of SCTP_PCO.
08:34:21.413412 SCTP.ttcn:113 Sent on SCTP_PCO to system @SCTPasp_Types.ASP_SCTP_SetSocketOptions : { Sctp_init := { sinit_num_ostreams := 10, sinit_max_instreams := 10, sinit_max_attempts := 0, sinit_max_init_timeo := 0 } }
08:34:21.413435 SCTP.ttcn:113 SCTPasp Test Port (SCTP_PCO): Calling outgoing_send (ASP_SCTP_SETSOCKETOPTIONS).
08:34:21.413459 SCTP.ttcn:113 SCTPasp Test Port (SCTP_PCO): Setting SCTP socket options (initmsg).
08:34:21.413484 SCTP.ttcn:113 Message enqueued on SCTP_PCO from system @SCTPasp_Types.ASP_SCTP_RESULT : { client_id := 6, error_status := false, error_message := omit } id 2
08:34:21.413507 SCTP.ttcn:113 SCTPasp Test Port (SCTP_PCO): Leaving outgoing_send (ASP_SCTP_SETSOCKETOPTIONS).
08:34:21.413528 SCTP.ttcn:114 Warning: Re-starting timer t0, which is already active (running or expired).
08:34:21.413550 SCTP.ttcn:114 Start timer t0: 1 s
08:34:21.413573 SCTP.ttcn:117 Matching on port SCTP_PCO succeeded:  matched
08:34:21.413596 SCTP.ttcn:117 Receive operation on port SCTP_PCO succeeded, message from system(): @SCTPasp_Types.ASP_SCTP_RESULT : { client_id := 6, error_status := false, error_message := omit } id 2
08:34:21.413639 SCTP.ttcn:117 Message with id 2 was extracted from the queue of SCTP_PCO.



As transmission of some port events from the port to the TTCN-3 code is authorized during configuration
template ASP_SCTP_SetSocketOptions t_ASP_SCTP_EVENTS :=
//In simple mode, this is set from the cfg file, but in normal mode , one needs to send an ASP_SCTP_EVENTS to the port (after connect)
//This will be answered by an ASP_SCTP_RESULT
{
  Sctp_events :=
  {
    sctp_data_io_event := false,
    sctp_association_event := true,
    sctp_address_event := true,
    sctp_send_failure_event := false,
    sctp_peer_error_event := false,
    sctp_shutdown_event := false,
    sctp_partial_delivery_event := false,
    sctp_adaption_layer_event := false
  }
}


handling of these event ASPs is solved by using an altstep activated as default behaviour:

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


} 

:
:
//******************************************************
testcase tc_sctp0() runs on SCTP_CT  system System_CT {
//******************************************************
  var ASP_SCTP_RESULT  vl_result;
  var default v_def := activate(as_SCTP_EVENTS()); 
  timer t0:=1.0;



 map(self:SCTP_PCO, system:SCTP_PCO);

:
:

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

  all component.kill;
}





08:34:21.413666 SCTP.ttcn:121 Sent on SCTP_PCO to system @SCTPasp_Types.ASP_SCTP_SetSocketOptions : { Sctp_events := { sctp_data_io_event := false, sctp_association_event := true, sctp_address_event := true, sctp_send_failure_event := false, sctp_peer_error_event := false, sctp_shutdown_event := false, sctp_partial_delivery_event := false, sctp_adaption_layer_event := false } }
08:34:21.413690 SCTP.ttcn:121 SCTPasp Test Port (SCTP_PCO): Calling outgoing_send (ASP_SCTP_SETSOCKETOPTIONS).
08:34:21.413711 SCTP.ttcn:121 SCTPasp Test Port (SCTP_PCO): Leaving outgoing_send (ASP_SCTP_SETSOCKETOPTIONS).
08:34:21.413732 SCTP.ttcn:122 Warning: Re-starting timer t0, which is already active (running or expired).
08:34:21.413753 SCTP.ttcn:122 Start timer t0: 1 s
08:34:21.413778 SCTP.ttcn:123 SCTPasp Test Port (SCTP_PCO): Calling Event_Handler.
08:34:21.413801 SCTP.ttcn:123 SCTPasp Test Port (SCTP_PCO): Calling getmsg().
08:34:21.413824 SCTP.ttcn:123 SCTPasp Test Port (SCTP_PCO): getmsg(): [20] bytes received. Receiving buffer now has [20] bytes.
08:34:21.413846 SCTP.ttcn:123 SCTPasp Test Port (SCTP_PCO): Leaving getmsg(): whole message is received.
08:34:21.413866 SCTP.ttcn:123 SCTPasp Test Port (SCTP_PCO): Calling event_handler for an incoming notification.
08:34:21.413887 SCTP.ttcn:123 SCTPasp Test Port (SCTP_PCO): incoming SCTP_ASSOC_CHANGE event.
08:34:21.413911 SCTP.ttcn:123 Message enqueued on SCTP_PCO from system @SCTPasp_Types.ASP_SCTP_ASSOC_CHANGE : { client_id := 6, sac_state := SCTP_COMM_UP (0) } id 3
08:34:21.413935 SCTP.ttcn:125 Matching on port SCTP_PCO failed: Type of the first message in the queue is not @SCTPasp_Types.ASP_SCTP_RESULT.
08:34:21.413957 SCTP.ttcn:79 Matching on port SCTP_PCO succeeded:  matched
08:34:21.413980 SCTP.ttcn:79 Receive operation on port SCTP_PCO succeeded, message from system(): @SCTPasp_Types.ASP_SCTP_ASSOC_CHANGE : { client_id := 6, sac_state := SCTP_COMM_UP (0) } id 3
08:34:21.414002 SCTP.ttcn:79 Message with id 3 was extracted from the queue of SCTP_PCO.
08:34:21.414023 SCTP.ttcn:126 Default with id 1 (altstep as_SCTP_EVENTS) has reached a break statement. Skipping current alt statement or receiving operation.


A lot less is relied upon the content of the configuration file:

:
[MODULE_PARAMETERS]

SCTP.tsp_remotheost  :="127.0.0.1";
SCTP.tsp_sctpPort    := 5202;

[TESTPORT_PARAMETERS]
# Port in normal mode

system.SCTP_PCO.simple_mode := "no"
system.SCTP_PCO.reconnect := "no"
system.SCTP_PCO.server_mode := "no"
system.SCTP_PCO.debug := "yes"
:



The code execution is essentially the same, as shown by the server side log:

 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:49425.
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.





Titan logs, code , Makefile and config file are attached in form of a compressed file created with 'make archive' . Execution was done on a Ubuntu 18.04



Next, we'll look into using the IPL4 test port for the same functionality.

Best regards
Elemer

[Updated on: Sat, 29 February 2020 15:03]

Report message to a moderator

Previous Topic:SCTP support in Eclipse Titan part 1
Next Topic:keeping larger state tables in something more efficient than arrays
Goto Forum:
  


Current Time: Fri Apr 19 10:54:40 GMT 2024

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

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

Back to the top