# port

The keyword is used to define a test port. Ports facilitate communication between test components and between test components and the test system interface. Ports are always bidirectional.

- Each port shall be defined as being message-based(1) or procedure-based(2)
- A mixed port(3) is a shorthand notation for two ports: a message-based and a procedure-based
- Ports include a list of messages and/or procedures allowed to pass that port together with their direction (in, out, inout)

Related keywords:

- all
- in
- inout
- message
- mixed
- out
- procedure
- type

#### 1. Declaring a message-based port

### type port port_identifier message { [ in all | type_list; ] [ out all | type_list; ] [ inout all | type_list; ] };

- The type port keywords introduce the port definition.

- port_identifier is the name used to refer to the port. Must begin with a letter, may contain letters, numbers and underscore characters.
  According to the Naming convention, the suffix _PT is recommended.

- The message keyword indicates that only messages are allowed to pass through the port.

- The in keyword introduces the list of messages allowed to pass the port in the incoming direction..

- type_list enumerates the allowed message types separated by commas; all is used when no restriction applies.

- The out keyword introduces the list of messages allowed to pass the port in the outgoing direction..

- type_list enumerates the allowed message types separated by commas; all is used when no restriction applies.

- The inout keyword introduces the list of messages allowed to pass the port both in incoming and outgoing direction..

- type_list enumerates the allowed message types separated by commas; all is used when no restriction applies.

No element may be repeated within the curly brackets.

Example

#### 2. Declaring a procedure-based port

### type port port_identifier procedure { [ in all | type_list; ] [ out all | type_list; ] [ inout all | type_list; ] };

- The type port keywords introduce the port definition.

- port_identifier is the name used to refer to the port. Must begin with a letter, may contain letters, numbers and underscore characters.
  According to the Naming convention, the suffix _PT is recommended.

- The procedure keyword indicates that only procedures are allowed to be called through the port.

- The in keyword introduces the list of procedures allowed to be called on the port in the incoming direction..

- type_list enumerates the allowed signatures separated by commas; all is used when no restriction applies.

- The out keyword introduces the list of procedures allowed to be called on the port in the outgoing direction..

- type_list enumerates the allowed signatures separated by commas; all is used when no restriction applies.

- The inout keyword introduces the list of procedures allowed to be called on the port both in incoming and outgoing direction..

- type_list enumerates the allowed signatures separated by commas; all is used when no restriction applies.

No element may be repeated within the curly brackets.

Example

#### 3. Declaring a mixed port

### type port port_identifier mixed { [ in all | type_list; ] [ out all | type_list; ] [ inout all | type_list; ] };

> TITAN specific restriction compared to the standard:

Mixed ports are not implemented. When encountered in the TTCN-3 program, it will cause a compilation error.

- The type port keywords introduce the port definition.

- port_identifier is the name used to refer to the port. Must begin with a letter, may contain letters, numbers and underscore characters.
  According to the Naming convention, the suffix _PT is recommended.

- The mixed keyword indicates that both messages and signatures are allowed to pass through the port.

- The in keyword introduces the list of messages and signatures allowed to pass the port in the incoming direction..

- type_list enumerates the allowed messages and signatures separated by commas; all is used when no restriction applies.

- The out keyword introduces the list of messages and signatures allowed to pass the port in the outgoing direction..

- type_list enumerates the allowed messages and signatures separated by commas; all is used when no restriction applies.

- The inout keyword introduces the list of messages and signatures allowed to pass the port both in incoming and outgoing direction..

- type_list enumerates the allowed messages and signatures separated by commas; all is used when no restriction applies.

No element may be repeated within the curly brackets.

Example

Example 1:

type port MyMessagePortType_PT message {
in ASP_RxType1, ASP_RxType2;
out ASP_TxType;
inout integer, octetstring;
}

The message-based port called MyMessagePortType_PT is declared.
In incoming directions messages of type ASP_RxType1, ASP_RxType2,
in outgoing directions messages of type ASP_TxType1,
in both outgoing and incoming direction messages of type integer and octetstring
are allowed to pass the port.

Example 2:

type port MyProcedurePortType_PT procedure {
out Proc1, Proc2, Proc3
}

The procedure-based port called MyProcedurePortType_PT is declared.
In outgoing directions the signatures Proc1, Proc2 and Proc3 are allowed to pass the port.

Example 3:

type port MyAllMixedPortType_PT mixed {
inout all
}

The mixed port called MyAllMixedPortType_PT is declared.
In both outgoing and incoming direction all message types and all signatures defined in the module can be used at this port to communicate with either the system under test (SUT) or other test components.

BNF definition of port