Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 445d3391f759a324e974acb1d90c51a1d5ffbec9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000-2017 Ericsson Telecom AB
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v2.0
// which accompanies this distribution, and is available at
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
///////////////////////////////////////////////////////////////////////////////
//  File:               EPTF_COAP_LocalTransport_Definitions.ttcn
//  Description:
//  Rev:                R1A
//  Prodnr:             CNL 113 858
//  Updated:            2017-09-01
//  Contact:            http://ttcn.ericsson.se
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
//  Module: EPTF_COAP_LocalTransport_Definitions
// 
//  Purpose:
//    This module contains the definitions for the COAP load generator component
//
//  Module depends on:
//    - <EPTF_COAP_Transport_Definitions>
//    - <EPTF_CLL_Base_Definitions>
//    - <EPTF_CLL_Logging_Definitions>
//    - <EPTF_CLL_FBQ_Definitions>
//    - <EPTF_CLL_TransportIPL4_Definitions>
//    - <EPTF_CLL_RBTScheduler_Definitions>
//    - <IPL4asp_Types>
// 
//  Module Parameters:
//    tsp_EPTF_COAP_LocalTransport_debug - <tsp_EPTF_COAP_LGen_debug> - *boolean* - Enabled/disable debug logging
//    tsp_EPTF_COAP_LocalTransport_debugVerbose - <tsp_EPTF_COAP_LGen_debugVerbose> - *boolean* - Enable/disable verbose debug logging
//
//  Class Diagram:
//   (see EPTF_COAP_LocalTransport_Definitions.classes.jpg)
//
///////////////////////////////////////////////////////////////
module EPTF_COAP_LocalTransport_Definitions
{
  import from EPTF_COAP_Transport_Definitions all;
  import from EPTF_CLL_Base_Definitions all;
  import from EPTF_CLL_Logging_Definitions all;
  import from EPTF_CLL_FBQ_Definitions all;
  import from EPTF_CLL_TransportIPL4_Definitions all;
  import from EPTF_CLL_RBTScheduler_Definitions all;
  import from IPL4asp_Types all;

  modulepar boolean tsp_EPTF_COAP_LocalTransport_debug := false;
  modulepar boolean tsp_EPTF_COAP_LocalTransport_debugVerbose := false;

  const charstring c_COAP_Transport_LGenType := "COAP_Transport";

  const integer c_COAP_LocalTransport_Logging_WARNING := 0;
  const integer c_COAP_LocalTransport_Logging_DEBUG := 1;
  const integer c_COAP_LocalTransport_Logging_DEBUGV := 2;
  const integer c_COAP_LocalTransport_Logging_ERROR := 3;

 /*****************************************************************
   @startuml EPTF_COAP_LocalTransport_Definitions.classes.jpg
 
   class EPTF_COAP_LocalTransport_CT {
     boolean v_EPTF_COAP_LocalTransport_initialized
     integer v_EPTF_COAP_LocalTransport_loggingMaskId
     SocketEntry   v_COAP_LocalTransport_currentSocket
     SocketDB      v_COAP_LocalTransport_localSocketDB
     EPTF_COAP_Transport_Statistics v_EPTF_COAP_Transport_stats
     f_EPTF_COAP_LocalTransport_init()
     f_EPTF_COAP_LocalTransport_initLogging()
     f_EPTF_COAP_LocalTransport_cleanup()
     f_EPTF_COAP_IPL4asp_getMsgLen(in octetstring stream, inout ro_integer args)
     f_EPTF_COAP_IPL4asp_handleEvent(...)
     f_EPTF_COAP_IPL4asp_handleMessage(...)
     f_EPTF_COAP_LocalTransport_send(in EPTF_COAP_PDU pl_msg)
     f_EPTF_COAP_LocalTransport_transportApiRequest(EPTF_COAP_Transport_Request pl_req)
     f_EPTF_COAP_LocalTransport_startSocket(in Socket p_sock, in ProtoTuple p_proto, in integer p_eIdx, inout integer p_idx)
     f_EPTF_COAP_LocalTransport_startDTLS(in EPTF_COAP_Transport_dtlsConnect p_params, in integer p_eIdx, inout integer p_idx)
     f_EPTF_COAP_LocalTransport_IPL4_sendTo(...)
     f_EPTF_COAP_LocalTransport_IPL4_send(in integer pl_connId,in ProtoTuple  pl_proto,in octetstring pl_msg)
   }
   EPTF_COAP_LocalTransport_CT "1" --> "1\n.v_COAP_LocalTransport_localSocketDB" SocketDB
   EPTF_COAP_LocalTransport_CT "1" --> "0..1\n.v_COAP_LocalTransport_currentSocket" SocketEntry
   EPTF_COAP_LocalTransport_CT "1" --> "1\n.v_EPTF_COAP_Transport_stats" EPTF_COAP_Transport_Statistics
  
   class SocketEntry {  
     Socket          addr
     DTLSConnection  dtls
     ProtoTuple      proto
     ConnectionId    connId
     SocketState     state
     integer         eIdx
     f_EPTF_COAP_SocketEntry_hash(in SocketEntry p_entry)
     f_EPTF_COAP_Socket_hash(Socket p_sock)
   }
   SocketEntry "1" --> "0..1\n.dtls" DTLSConnection
  
   class SocketDB {
     EPTF_FreeBusyQueue queue
     SocketEntry_List data
     integer hashRef
     integer connId2eIdx_hashRef
     f_EPTF_COAP_LocalTransport_socketDB_init()
     f_EPTF_COAP_LocalTransport_socketDB_cleanUp()
     f_EPTF_COAP_LocalTransport_socketDB_add(in SocketEntry p_entry)
     f_EPTF_COAP_LocalTransport_socketDB_lookUp_localAddr(in Socket p_localAddr)
     f_EPTF_COAP_LocalTransport_socketDB_lookUp_dtlsConnection(in Socket p_local, in Socket p_remote)
     f_EPTF_COAP_LocalTransport_socketDB_lookUp_connId(in integer p_connId)
     f_EPTF_COAP_LocalTransport_socketDB_get(in integer p_idx, inout SocketEntry p_sock)
     f_EPTF_COAP_LocalTransport_socketDB_remove(in integer p_idx)
   }
   SocketDB "1" --> "*\n.data" SocketEntry
  
   class DTLSConnection {
    Socket          remoteAddr
    charstring      pskIndetity
    charstring      pskKey
    f_EPTF_COAP_DTLSConnection_hash(in Socket p_local, in Socket p_remote)
   }
  
   class EPTF_COAP_Transport_Statistics {
    integer   nofOpenConnections
    integer   nofTransportWarnings
    float     nofReceivedMessages
    float     nofSentMessages
    float     nofReceivedBytes
    float     nofSentBytes
   }
   @enduml
  ******************************************************************/
 /*****************************************************************
   @startuml EPTF_COAP_LocalTransport_Definitions.EPTF_COAP_LocalTransport_CT.jpg
     class EPTF_COAP_LocalTransport_CT {
       boolean v_EPTF_COAP_LocalTransport_initialized
       integer v_EPTF_COAP_LocalTransport_loggingMaskId
       SocketEntry   v_COAP_LocalTransport_currentSocket
       SocketDB      v_COAP_LocalTransport_localSocketDB
       EPTF_COAP_Transport_Statistics v_EPTF_COAP_Transport_stats
       f_EPTF_COAP_LocalTransport_init()
       f_EPTF_COAP_LocalTransport_initLogging()
       f_EPTF_COAP_LocalTransport_cleanup()
       f_EPTF_COAP_IPL4asp_getMsgLen(in octetstring stream, inout ro_integer args)
       f_EPTF_COAP_IPL4asp_handleEvent(...)
       f_EPTF_COAP_IPL4asp_handleMessage(...)
       f_EPTF_COAP_LocalTransport_send(in EPTF_COAP_PDU pl_msg)
       f_EPTF_COAP_LocalTransport_transportApiRequest(EPTF_COAP_Transport_Request pl_req)
       f_EPTF_COAP_LocalTransport_startSocket(in Socket p_sock, in ProtoTuple p_proto, in integer p_eIdx, inout integer p_idx)
       f_EPTF_COAP_LocalTransport_startDTLS(in EPTF_COAP_Transport_dtlsConnect p_params, in integer p_eIdx, inout integer p_idx)
       f_EPTF_COAP_LocalTransport_IPL4_sendTo(...)
       f_EPTF_COAP_LocalTransport_IPL4_send(in integer pl_connId,in ProtoTuple  pl_proto,in octetstring pl_msg)
     }
   @enduml
  ******************************************************************/
  ///////////////////////////////////////////////////////////
  // Type: EPTF_COAP_LGen_CT
  //
  // Purpose:
  //   COAP local transport component
  //
  // Class:
  //   (see EPTF_COAP_LocalTransport_Definitions.EPTF_COAP_LocalTransport_CT.jpg)
  //
  // Extensions:
  //  - <EPTF_COAP_Transport_Provider_CT>
  //  - <EPTF_TransportIPL4_CT>
  //  - <EPTF_Base_CT>
  //  - <EPTF_Logging_CT>
  //  - <EPTF_Scheduler_CT>
  //
  // Ports:
  //   -
  //
  // Timers:
  //   -
  //
  // Variables:
  //   v_EPTF_COAP_LocalTransport_initialized  - *boolean* - Flag to indicate if the init function was already called
  //   v_EPTF_COAP_LocalTransport_loggingMaskId - *integer* - logging mask id
  //   v_EPTF_COAP_Transport_stats - <EPTF_COAP_Transport_Statistics> - Counters for transport statistics
  // 
  // Instance databases:
  //   v_COAP_LocalTransport_localSocketDB - <SocketDB> - Storing the managed transport endpoints
  //
  // Related Functions:
  //   - <f_EPTF_COAP_LocalTransport_init> ()
  //   - <f_EPTF_COAP_LocalTransport_initLogging> ()
  //   - <f_EPTF_COAP_LocalTransport_cleanup> ()
  //   - <f_EPTF_COAP_IPL4asp_getMsgLen> (in *octetstring* stream, inout <ro_integer> args)
  //   - <f_EPTF_COAP_IPL4asp_handleEvent> (...)
  //   - <f_EPTF_COAP_IPL4asp_handleMessage> (...)
  //   - <f_EPTF_COAP_LocalTransport_send> (in <EPTF_COAP_PDU> pl_msg)
  //   - <f_EPTF_COAP_LocalTransport_transportApiRequest> (<EPTF_COAP_Transport_Request> pl_req)
  //   - <f_EPTF_COAP_LocalTransport_startSocket> (in <Socket> p_sock, in <ProtoTuple> p_proto, in *integer* p_eIdx, inout *integer* p_idx)
  //   - <f_EPTF_COAP_LocalTransport_startDTLS> (in <EPTF_COAP_Transport_dtlsConnect> p_params, in *integer* p_eIdx, inout *integer* p_idx)
  //   - <f_EPTF_COAP_LocalTransport_IPL4_sendTo> (...)
  //   - <f_EPTF_COAP_LocalTransport_IPL4_send> (in *integer* pl_connId,in <ProtoTuple>  pl_proto, in *octetstring* pl_msg)
  ///////////////////////////////////////////////////////////
  type component EPTF_COAP_LocalTransport_CT
    extends EPTF_COAP_Transport_Provider_CT, EPTF_Base_CT, 
    EPTF_Logging_CT, EPTF_TransportIPL4_CT, EPTF_Scheduler_CT
  {
    var boolean       v_EPTF_COAP_LocalTransport_initialized := false;
    var integer       v_EPTF_COAP_LocalTransport_loggingMaskId;

    var SocketEntry   v_COAP_LocalTransport_currentSocket;

    // database:
    var SocketDB      v_COAP_LocalTransport_localSocketDB;

    // statistics:
    var EPTF_COAP_Transport_Statistics  v_EPTF_COAP_Transport_stats;
  }

 /*****************************************************************
   @startuml EPTF_COAP_LocalTransport_Definitions.SocketEntry.jpg
   class SocketEntry {  
     Socket          addr
     DTLSConnection  dtls
     ProtoTuple      proto
     ConnectionId    connId
     SocketState     state
     integer         eId
     f_EPTF_COAP_SocketEntry_hash(in SocketEntry p_entry)
     f_EPTF_COAP_Socket_hash(Socket p_sock)
   }
   @enduml
  ******************************************************************/
  ///////////////////////////////////////////////////////////
  //  Type: SocketEntry
  //
  //  Purpose:
  //    Storing the transport related data of a COAP transport endpoint
  //
  //  Class:
  //    (see EPTF_COAP_LocalTransport_Definitions.SocketEntry.jpg)
  //
  //  Elements:
  //    addr  - <Socket> - local address and local port
  //    dtls  - <DTLSConnection> - in case DTLS (PSK) is used, the remote address and port with keys are stored here
  //    proto  - <ProtoTuple> - transport protocol description
  //    connId  - <ConnectionId> - connection id from the IPL4 transport layer
  //    state  - <SocketState> - state of the socket
  //    eIdx  - <integer> - the index of the entity (COAP device) who owns this socket
  //
  //  Related Functions:
  //    - <f_EPTF_COAP_SocketEntry_hash> (in <SocketEntry> p_entry)
  //    - <f_EPTF_COAP_Socket_hash> (<Socket> p_sock)
  ///////////////////////////////////////////////////////////  
  type record SocketEntry
  {
    Socket          addr,
    DTLSConnection  dtls optional,
    ProtoTuple      proto,
    ConnectionId    connId,
    SocketState     state,
    integer         eIdx
  }

  ///////////////////////////////////////////////////////////
  //  Enum: SocketState
  //
  //  Purpose:
  //    States of a <SocketEntry>
  //
  //  Elements:
  //    - UNUSED
  //    - CLOSED
  //    - OPENED
  //    - TEMPORARY_UNAVAILABLE
  ///////////////////////////////////////////////////////////
  type enumerated SocketState
  {
    UNUSED,
    CLOSED,
    OPENED,
    TEMPORARY_UNAVAILABLE
  }

  const SocketEntry c_SocketEntry_init :=
  {
    addr := {
      hostName := "",
      portNumber := -1
    },
    dtls := omit,
    proto := { udp := {} },
    connId := -1,
    state := UNUSED,
    eIdx := -1
  }

  ///////////////////////////////////////////////////////////
  //  Type: SocketEntry_List
  //
  //  Purpose:
  //    List of <SocketEntry>
  ///////////////////////////////////////////////////////////
  type record of SocketEntry SocketEntry_List;

 /*****************************************************************
   @startuml EPTF_COAP_LocalTransport_Definitions.SocketDB.jpg
   class SocketDB {
     EPTF_FreeBusyQueue queue
     SocketEntry_List data
     integer hashRef
     integer connId2eIdx_hashRef
     f_EPTF_COAP_LocalTransport_socketDB_init()
     f_EPTF_COAP_LocalTransport_socketDB_cleanUp()
     f_EPTF_COAP_LocalTransport_socketDB_add(in SocketEntry p_entry)
     f_EPTF_COAP_LocalTransport_socketDB_lookUp_localAddr(in Socket p_localAddr)
     f_EPTF_COAP_LocalTransport_socketDB_lookUp_dtlsConnection(in Socket p_local, in Socket p_remote)
     f_EPTF_COAP_LocalTransport_socketDB_lookUp_connId(in integer p_connId)
     f_EPTF_COAP_LocalTransport_socketDB_get(in integer p_idx, inout SocketEntry p_sock)
     f_EPTF_COAP_LocalTransport_socketDB_remove(in integer p_idx)
   }
   @enduml
  ******************************************************************/
  ///////////////////////////////////////////////////////////
  //  Type: SocketDB
  //
  //  Purpose:
  //    Storing <SocketEntry> instances
  //
  //  Class:
  //    (see EPTF_COAP_LocalTransport_Definitions.SocketDB.jpg)
  //
  //  Elements:
  //    queue  - <EPTF_FreeBusyQueue> - FBQ for the stored elements
  //    data  - <COAP_Transaction_List> - elements
  //    hashRef - *integer* - hash id of the hash map
  //    connId2eIdx_hashRef - *integer* - hash id of the int2int hash map where key: connId -> value: eIdx
  //
  //  Related Functions:
  //   - <f_EPTF_COAP_LocalTransport_socketDB_init> ()
  //   - <f_EPTF_COAP_LocalTransport_socketDB_cleanUp> ()
  //   - <f_EPTF_COAP_LocalTransport_socketDB_add> (in <SocketEntry> p_entry)
  //   - <f_EPTF_COAP_LocalTransport_socketDB_lookUp_localAddr> (in <Socket> p_localAddr)
  //   - <f_EPTF_COAP_LocalTransport_socketDB_lookUp_dtlsConnection> (in <Socket> p_local, in <Socket> p_remote)
  //   - <f_EPTF_COAP_LocalTransport_socketDB_lookUp_connId> (in *integer* p_connId)
  //   - <f_EPTF_COAP_LocalTransport_socketDB_get> (in *integer* p_idx, inout <SocketEntry> p_sock)
  //   - <f_EPTF_COAP_LocalTransport_socketDB_remove> (in *integer* p_idx)
  ///////////////////////////////////////////////////////////  
  type record SocketDB
  {
    EPTF_FreeBusyQueue queue,
    SocketEntry_List data,
    integer hashRef,
    integer connId2eIdx_hashRef
  }
  const charstring c_EPTF_COAP_LocalTransport_SocketDB := "EPTF_COAP_LocalTransport_SocketDB";
  const charstring c_EPTF_COAP_LocalTransport_SocketDB_connId2eIdx_hashRef := "EPTF_COAP_LocalTransport_SocketDB_connId2eIdx_hashRef";

 /*****************************************************************
   @startuml EPTF_COAP_LocalTransport_Definitions.DTLSConnection.jpg
   class DTLSConnection {
    Socket          remoteAddr
    charstring      pskIndetity
    charstring      pskKey
    f_EPTF_COAP_DTLSConnection_hash(in Socket p_local, in Socket p_remote)
   }
   @enduml
  ******************************************************************/
  ///////////////////////////////////////////////////////////
  //  Type: DTLSConnection
  //
  //  Purpose:
  //    Storing the DTLS transport related data of a COAP transport endpoint
  //
  //  Class:
  //    (see EPTF_COAP_LocalTransport_Definitions.DTLSConnection.jpg)
  //
  //  Elements:
  //    remoteAddr  - <Socket> - remote address and remote port of the DTLS connection
  //    pskIndetity  - *charstring* - identity used for PSK authnetication
  //    pskKey  - *charstring* - key used for PSK authnetication
  //
  //  Related Functions:
  //   - <f_EPTF_COAP_DTLSConnection_hash> (in <Socket> p_local, in <Socket> p_remote)
  ///////////////////////////////////////////////////////////  
  type record DTLSConnection
  {
    Socket          remoteAddr,
    charstring      pskIndetity optional,
    charstring      pskKey optional
  }
  
  const DTLSConnection c_DTLSConnection_init :=
  {
    remoteAddr := {hostName := "", portNumber := -1 },
    pskIndetity := omit,
    pskKey := omit
  }

 /*****************************************************************
   @startuml EPTF_COAP_LocalTransport_Definitions.EPTF_COAP_Transport_Statistics.jpg
   class EPTF_COAP_Transport_Statistics {
    integer   nofOpenConnections
    integer   nofTransportWarnings
    float     nofReceivedMessages
    float     nofSentMessages
    float     nofReceivedBytes
    float     nofSentBytes
   }
   @enduml
  ******************************************************************/
  ///////////////////////////////////////////////////////////
  //  Type: EPTF_COAP_Transport_Statistics
  //
  //  Purpose:
  //    Storing counters for transport related statistics
  //
  //  Class:
  //    (see EPTF_COAP_LocalTransport_Definitions.EPTF_COAP_Transport_Statistics.jpg)
  //
  //  Elements:
  //    nofOpenConnections  - *integer* - number of open connection
  //    nofTransportWarnings  - *integer* - number of transport warnings issued so far during the execution
  //    nofReceivedMessages  - *float* - number of received messages
  //    nofSentMessages  - *float* - number of sent messages
  //    nofReceivedBytes  - *float* - number of received bytes
  //    nofSentBytes  - *float* - number of sent bytes
  /////////////////////////////////////////////////////////// 
  type record EPTF_COAP_Transport_Statistics
  {
    integer   nofOpenConnections,
    integer   nofTransportWarnings,
    float     nofReceivedMessages,
    float     nofSentMessages,
    float     nofReceivedBytes,
    float     nofSentBytes
  }

  const EPTF_COAP_Transport_Statistics c_EPTF_COAP_Transport_Statistics_empty :=
  {
    nofOpenConnections := 0,
    nofTransportWarnings := 0,
    nofReceivedMessages := 0.0,
    nofSentMessages := 0.0,
    nofReceivedBytes := 0.0,
    nofSentBytes := 0.0
  }
}

Back to the top