apidocs comments added

Signed-off-by: eantwuh <antal.wu-hen-chang@ericsson.com>
diff --git a/src/EPTF_MQTT_LGen_Definitions.ttcn b/src/EPTF_MQTT_LGen_Definitions.ttcn
index afab7f2..a0780ca 100644
--- a/src/EPTF_MQTT_LGen_Definitions.ttcn
+++ b/src/EPTF_MQTT_LGen_Definitions.ttcn
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2000-2019 Ericsson Telecom AB
+// Copyright (c) 2000-2020 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
@@ -9,11 +9,79 @@
 ///////////////////////////////////////////////////////////////////////////////
 //  File:               EPTF_MQTT_LGen_Definitions.ttcn
 //  Description:
-//  Rev:                R1A
+//  Rev:                <RnXnn>
 //  Prodnr:             CNL 113 860
-//  Updated:            2017-09-01
+//  Updated:            2020-01-07
 //  Contact:            http://ttcn.ericsson.se
 ///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+//  Module: EPTF_MQTT_LGen_Definitions
+// 
+//  Purpose:
+//    This module contains the definitions for the MQTT load generator component
+//
+//  Module depends on:
+//    - <EPTF_MQTT_Transport_Definitions>
+//    - <EPTF_CLL_LGenBase_Definitions>
+//    - <EPTF_CLL_Logging_Definitions>
+//    - <EPTF_CLL_FBQ_Definitions>
+//    - <EPTF_CLL_Common_Definitions>
+//    - <Socket_API_Definitions>
+//    - <MQTT_v3_1_1_Types>
+// 
+//  Module Parameters:
+//    tsp_EPTF_MQTT_LGen_debug - <tsp_EPTF_MQTT_LGen_debug> - *boolean* - Enabled/disable debug logging
+//    tsp_EPTF_MQTT_LGen_debugVerbose - <tsp_EPTF_MQTT_LGen_debugVerbose> - *boolean* - Enabled/disable verbosity of debug logging
+//    tsp_EPTF_MQTT_LGen_maxBindableCtx - <tsp_EPTF_MQTT_LGen_maxBindableCtx> - *integer* - Maximum number of context to bind(?)
+//    tsp_EPTF_MQTT_LGen_templates - <tsp_EPTF_MQTT_LGen_templates> - <MQTT_Template_List> - MQTT message template definitions for sending
+//    tsp_EPTF_MQTT_PUBLISH_responseWatchdog - <tsp_EPTF_MQTT_PUBLISH_responseWatchdog> - *float* - Watchdog timer value to wait responses to an MQTT PUBLISH message
+//
+//  Events:
+//    MQTT transport success - <c_MQTT_eventIdx_transportSucc>, <c_MQTT_eventName_transportSucc>
+//    MQTT transport fail - <c_MQTT_eventIdx_transportFail>, <c_MQTT_eventName_transportFail>
+//    MQTT transport closed - <c_MQTT_eventIdx_transportClosed>, <c_MQTT_eventName_transportClosed>
+//    CONNACK accepted - <c_MQTT_eventIdx_CONNACK_Accepted>, <c_MQTT_eventName_CONNACK_Accepted>
+//    CONNAK refused - <c_MQTT_eventIdx_CONNACK_Refused>, <c_MQTT_eventName_CONNACK_Refused>
+//    SUBACK accepted - <c_MQTT_eventIdx_SUBACK_Accepted>, <c_MQTT_eventName_SUBACK_Accepted>
+//    SUBACK refused <c_MQTT_eventIdx_SUBACK_Refused>, <c_MQTT_eventName_SUBACK_Refused>
+//    UNSUBACK - <c_MQTT_eventIdx_UNSUBACK>, <c_MQTT_eventName_UNSUBACK>
+//    PUBLISH - <c_MQTT_eventIdx_PUBLISH>, <c_MQTT_eventName_PUBLISH>
+//    PING request - <c_MQTT_eventIdx_PING_Request>, <c_MQTT_eventName_PING_Request>
+//    PING response - <c_MQTT_eventIdx_PING_Response>, <c_MQTT_eventName_PING_Response>
+//    PUBACK - <c_MQTT_eventIdx_PUBACK>, <c_MQTT_eventName_PUBACK>
+//    PUBREC - <c_MQTT_eventIdx_PUBREC>, <c_MQTT_eventName_PUBREC>
+//    PUBREL - <c_MQTT_eventIdx_PUBREL>, <c_MQTT_eventName_PUBREL>
+//    PUBCOMP - <c_MQTT_eventIdx_PUBCOMP>, <c_MQTT_eventName_PUBCOMP>
+//    PUBLISH teimout - <c_MQTT_eventIdx_PUBLISH_Timeout>, <c_MQTT_eventName_PUBLISH_Timeout>
+//
+//  TestSteps:
+//    MQTT init - <f_MQTT_step_init>, <c_MQTT_stepIdx_init>, <c_MQTT_stepName_init>
+//    MQTT cleanUp - <f_MQTT_step_cleanUp>, <c_MQTT_stepIdx_init>, <c_MQTT_stepIdx_init>
+//    set local address - <f_MQTT_step_setLocalAddress_byVars>, <c_MQTT_stepIdx_setLocalAddress_byVars>, <c_MQTT_stepName_setLocalAddress_byVars>
+//    set remote address - <f_MQTT_step_setRemoteAddress_byVars>, <c_MQTT_stepIdx_setRemoteAddress_byVars>, <c_MQTT_stepName_setRemoteAddress_byVars>
+//    transport connect - <f_MQTT_step_transportConnect>, <c_MQTT_stepIdx_transportConnect>, <c_MQTT_stepName_transportConnect>
+//    transport close - <f_MQTT_step_transportClose>, <c_MQTT_stepIdx_transportClose>, <c_MQTT_stepName_transportClose>
+//    start listening - <f_MQTT_step_startListening>, <c_MQTT_stepIdx_startListening>, <c_MQTT_stepName_startListening>
+//    load MQTT template - <f_MQTT_step_loadTemplate_byIntIdx>, <c_MQTT_stepIdx_loadTemplate_byIntIdx>, <c_MQTT_stepName_loadTemplate_byIntIdx>
+//                         <f_MQTT_step_loadTemplate_byStringId>, <c_MQTT_stepIdx_loadTemplate_byStringId>, <c_MQTT_stepName_loadTemplate_byStringId>
+//    send message - <f_MQTT_step_send>, <c_MQTT_stepIdx_send>, <c_MQTT_stepName_send>
+//    set topic - <f_MQTT_step_setTopic_stringParam>, <c_MQTT_stepIdx_setTopic_stringParam>, <c_MQTT_stepName_setTopic_stringParam>
+//                <f_MQTT_step_setTopic_add_stringParam>, <c_MQTT_stepIdx_setTopic_add_stringParam>, <c_MQTT_stepName_setTopic_add_stringParam>
+//                <f_MQTT_step_setTopic_add_varParams>, <c_MQTT_stepIdx_setTopic_add_varParams>, <c_MQTT_stepName_setTopic_add_varParams>
+//                <f_MQTT_step_setTopic_add_clientId>, <c_MQTT_stepIdx_setTopic_add_clientId>, <c_MQTT_stepName_setTopic_add_clientId>
+//    set QoS - <f_MQTT_step_setQos_intParam>, <c_MQTT_stepIdx_setQos_intParam>, <c_MQTT_stepName_setQos_intParam>
+//    set publish message - <f_MQTT_step_setPublishMessage_stringParam>, <c_MQTT_stepIdx_setPublishMessage_stringParam>, <c_MQTT_stepName_setPublishMessage_stringParam>
+//                          <f_MQTT_step_setPublishMessage_add_stringParam>, <c_MQTT_stepIdx_setPublishMessage_add_stringParam>, <c_MQTT_stepName_setPublishMessage_add_stringParam>
+//                          <f_MQTT_step_setPublishMessage_add_varParams>, <c_MQTT_stepIdx_setPublishMessage_add_varParams>, <c_MQTT_stepName_setPublishMessage_add_varParams>
+//                          <f_MQTT_step_setPublishMessage_add_clientId>, <c_MQTT_stepIdx_setPublishMessage_add_clientId>, <c_MQTT_stepName_setPublishMessage_add_clientId>
+//    MQTT - <f_MQTT_step_reportPingResponse>, <c_MQTT_stepIdx_reportPingResponse>, <c_MQTT_stepName_reportPingResponse>
+//    MQTT - <f_MQTT_step_reportPublishResponse>, <c_MQTT_stepIdx_reportPublishResponse>, <c_MQTT_stepName_reportPublishResponse>
+//
+//  Class Diagram:
+//   (see EPTF_MQTT_LGen_Definitions.classes.jpg)
+//
+///////////////////////////////////////////////////////////////
 module EPTF_MQTT_LGen_Definitions
 {
   import from EPTF_MQTT_Transport_Definitions all;
@@ -24,12 +92,75 @@
   import from Socket_API_Definitions all;
   import from MQTT_v3_1_1_Types all;
 
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_LGen_debug
+  // 
+  //  Purpose:
+  //    Enabled/disable debug logging
+  //  
+  //  Type:
+  //     *boolean*
+  //
+  //  Default value:
+  //     *false*
+  ///////////////////////////////////////////////////////////
   modulepar boolean tsp_EPTF_MQTT_LGen_debug := false;
+
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_LGen_debugVerbose
+  // 
+  //  Purpose:
+  //    Enabled/disable verbosity of debug logging
+  //  
+  //  Type:
+  //     *boolean*
+  //
+  //  Default value:
+  //     *false*
+  ///////////////////////////////////////////////////////////
   modulepar boolean tsp_EPTF_MQTT_LGen_debugVerbose := false;
+
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_LGen_maxBindableCtx
+  // 
+  //  Purpose:
+  //    Can be used to limit the maximum number of contexts
+  //  set it to -1 otherwise.
+  //  
+  //  Type:
+  //     *integer*
+  //
+  //  Default value:
+  //     *-1*
+  ///////////////////////////////////////////////////////////
   modulepar integer tsp_EPTF_MQTT_LGen_maxBindableCtx := -1;
 
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_LGen_templates
+  // 
+  //  Purpose:
+  //    MQTT message template definitions for sending
+  //
+  //  Type:
+  //     <MQTT_Template_List>
+  //
+  //  Default value:
+  //     Empty list: {}
+  ///////////////////////////////////////////////////////////
   modulepar MQTT_Template_List tsp_EPTF_MQTT_LGen_templates := {};
 
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_PUBLISH_responseWatchdog
+  // 
+  //  Purpose:
+  //    Watchdog timer value to wait responses to an MQTT PUBLISH message
+  //
+  //  Type:
+  //     <MQTT_Template_List>
+  //
+  //  Default value:
+  //     Empty list: {}
+  ///////////////////////////////////////////////////////////
   modulepar float tsp_EPTF_MQTT_PUBLISH_responseWatchdog := 0.0;
 
   const integer c_MQTT_LGen_Logging_WARNING := 0;
@@ -39,20 +170,327 @@
 
   const charstring c_MQTT_behaviorType := "MQTT Behavior";
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.classes.jpg
+
+     class EPTF_MQTT_LGen_CT {
+       boolean v_MQTT_initialized
+       integer v_MQTT_bIdx
+       integer v_MQTT_loggingMaskId
+       MQTT_Address_DB      v_MQTT_addressDB
+       MQTT_Template_DB     v_MQTT_templateDB
+       MQTT_Session_DB      v_MQTT_sessionDB
+       MQTT_Subscription_DB v_MQTT_subscriptionDB
+       MQTT_Publish_DB v_MQTT_publishDB
+       MQTT_StepCtx    v_MQTT_ctx
+       MQTT_Session    v_MQTT_session
+       MQTT_Subscription v_MQTT_subscription
+       MQTT_Publish      v_MQTT_publish
+       EPTF_MQTT_PDU     v_MQTT_msgToProcess
+       EPTF_MQTT_PDU     v_MQTT_msgToSend
+       fcb_EPTF_MQTT_messageReceived vf_MQTT_msgReceived
+       f_EPTF_MQTT_LGen_init(in charstring pl_name)
+       f_EPTF_MQTT_LGen_initLogging()
+       f_MQTT_cleanUp()
+       f_MQTT_eCtxBind(in integer pl_eIdx)
+       f_MQTT_eCtxUnbind(in integer pl_eIdx)
+       f_MQTT_eCtxReset(in integer pl_eIdx)
+       f_EPTF_MQTT_declareEvents()
+       f_EPTF_MQTT_declareSteps()
+       f_EPTF_MQTT_LGen_receiveMessage(in EPTF_MQTT_PDU pl_message)
+       f_EPTF_MQTT_LGen_receiveEvent(in ASP_Event p_event)
+       f_EPTF_MQTT_LGen_transportApiResponse(in EPTF_MQTT_Transport_Response pl_rsp)
+       f_EPTF_MQTT_LGen_send(inout EPTF_MQTT_PDU p_msg)
+       f_EPTF_MQTT_stack_fromApp(inout EPTF_MQTT_PDU p_msg, in MQTT_StepCtx p_ctx)
+       f_EPTF_MQTT_stack_fromEnv(inout EPTF_MQTT_PDU p_msg)
+       f_EPTF_MQTT_isFsmInitialized(in integer pl_eIdx, in integer pl_fsmIdx, inout integer pl_sessionIdx)
+       f_EPTF_MQTT_Logging_VERBOSE(in @lazy charstring pl_message)
+       f_EPTF_MQTT_Logging_DEBUG(in @lazy charstring pl_message)
+       f_EPTF_MQTT_Logging_WARNING(in @lazy charstring pl_message)
+       f_EPTF_MQTT_Logging_ERROR(in @lazy charstring pl_message)
+       f_EPTF_MQTT_dispatchEvent(in integer pl_eventIdx, in integer pl_eIdx, in integer pl_fsmCtx, in EPTF_IntegerList pl_reportedArgs)
+     }
+     EPTF_MQTT_LGen_CT "1" --> "1\n.v_MQTT_addressDB" MQTT_Address_DB
+     EPTF_MQTT_LGen_CT "1" --> "1\n.v_MQTT_templateDB" MQTT_Template_DB
+     EPTF_MQTT_LGen_CT "1" --> "1\n.v_MQTT_sessionDB" MQTT_Session_DB
+     EPTF_MQTT_LGen_CT "1" --> "1\n.v_MQTT_subscriptionDB" v_MQTT_subscriptionDB
+     EPTF_MQTT_LGen_CT "1" --> "1\n.v_MQTT_publishDB" v_MQTT_publishDB
+  
+     class MQTT_Address_DB {
+       EPTF_FreeBusyQueue     queue
+       MQTT_Address_List      data
+       integer                hashRef
+       f_EPTF_MQTT_addressDB_init()
+       f_EPTF_MQTT_addressDB_add(in Socket p_addr, inout integer p_idx)
+       f_EPTF_MQTT_addressDB_lookUp(in Socket p_sock)
+       f_EPTF_MQTT_addressDB_get(inout Socket p_addr, in integer p_idx)
+       f_EPTF_MQTT_addressDB_Socket2String(Socket p_sock)
+       f_EPTF_MQTT_addressDB_cleanUp()
+     }
+     MQTT_Address_DB "1" --> "*\n.data[]" Socket
+  
+     class MQTT_Template_DB {
+       EPTF_FreeBusyQueue queue
+       MQTT_Template_List data
+       integer hashRef
+       f_EPTF_MQTT_templateDB_init()
+       f_EPTF_MQTT_templateDB_add(in MQTT_Template p_template)
+       f_EPTF_MQTT_templateDB_lookUp(in charstring p_id)
+       f_EPTF_MQTT_templateDB_get(in integer p_idx, inout Socket MQTT_v3_1_1_ReqResp p_pdu)
+       f_EPTF_MQTT_templateDB_cleanUp()
+     }
+     MQTT_Template_DB "1" --> "*\n.data[]" MQTT_Template
+  
+     class MQTT_Session_DB {
+       EPTF_FreeBusyQueue  queue
+       MQTT_Session_List   data
+       integer             hashRef
+       f_EPTF_MQTT_sessionDB_init()
+       f_EPTF_MQTT_sessionDB_add(in MQTT_Session p_session)
+       f_EPTF_MQTT_sessionDB_lookUp(in Socket p_sock)
+       f_EPTF_MQTT_sessionDB_get(in integer p_idx, inout MQTT_Session p_session)
+       f_EPTF_MQTT_sessionDB_setKey(in integer p_idx)
+       f_EPTF_MQTT_sessionDB_check(in integer p_idx)
+       f_EPTF_MQTT_sessionDB_remove(in integer p_idx)
+       f_EPTF_MQTT_sessionDB_addrHash(in Socket p_sock)
+       f_EPTF_MQTT_sessionDB_cleanUp()
+     }
+     MQTT_Session_DB "1" --> "*\n.data[]" MQTT_Session
+  
+     class MQTT_Session {
+       integer eIdx
+       integer fsmIdx
+       integer localAddrIdx
+       integer remoteAddrIdx
+       charstring clientId
+       float keepAliveTime
+       integer nextPacketId,
+       integer[] subscriptionRefs
+       integer[] publishRefs
+       integer keepaliveTimer
+       boolean reportPingResponse
+       boolean reportPublishResponse
+       MQTT_Session_State state
+       f_EPTF_MQTT_session_fromApp(inout EPTF_MQTT_PDU p_msg, in integer p_sIdx)
+       f_EPTF_MQTT_session_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_sIdx)
+       f_EPTF_MQTT_session_keepalive(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex)
+       f_EPTF_MQTT_session_startT_keepalive(in integer pl_sIdx, in float pl_time)
+       f_EPTF_MQTT_session_cancelT_keepalive(in integer pl_sessionIdx)
+       f_EPTF_MQTT_session_getNextPacketId(in MQTT_StepCtx p_ctx)
+       f_EPTF_MQTT_session_setState(in integer p_sessionIdx, in MQTT_Session_State p_nextState)
+       f_EPTF_MQTT_session_send(in integer p_sessionIdx, inout EPTF_MQTT_PDU p_msg)
+       f_EPTF_MQTT_session_registerSubscription(in integer p_sessionIdx, in integer p_subIdx)
+       f_EPTF_MQTT_session_deregisterSubscription(in integer p_sessionIdx, in integer p_subIdx)
+       f_EPTF_MQTT_session_registerPublish(in integer p_sessionIdx, in integer p_pubIdx)
+       f_EPTF_MQTT_session_deregisterPublish(in integer p_sessionIdx, in integer p_pubIdx)
+       f_EPTF_MQTT_session_remove(in integer p_sessionIdx)
+     }
+     MQTT_Session "1" --> "1\n.localAddrIdx" Socket
+     MQTT_Session "1" --> "1\n.remoteAddrIdx" Socket
+     MQTT_Session "1\n.sessionIdx" <--> "*\n.subscriptionRefs[]" MQTT_Subscription
+     MQTT_Session "1\n.sessionIdx" <--> "*\n.publishRefs[]" MQTT_Publish  
+
+     class MQTT_Subscription_DB {
+       EPTF_FreeBusyQueue     queue
+       MQTT_Subscription_List data
+       integer                hashRef
+       f_EPTF_MQTT_subscriptionDB_init()
+       f_EPTF_MQTT_subscriptionDB_add(in MQTT_Subscription p_sub)
+       f_EPTF_MQTT_subscriptionDB_setKey_packetId(in integer p_idx, in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_removeKey_packetId(in integer p_idx, in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_lookUp_packetId(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_lookUp_topicName(in integer p_sessionIdx, in charstring p_topicName)
+       f_EPTF_MQTT_subscriptionDB_get(in integer p_idx, inout MQTT_Subscription p_sub)
+       f_EPTF_MQTT_subscriptionDB_check(in integer p_idx)
+       f_EPTF_MQTT_subscriptionDB_remove(in integer p_idx)
+       f_EPTF_MQTT_subscriptionDB_packetIdHash(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_topicHash(in integer p_sessionIdx, in charstring p_topic)
+       f_EPTF_MQTT_subscriptionDB_cleanUp()
+     }
+     MQTT_Subscription_DB "1" --> "*\n.data[]" MQTT_Subscription
+  
+     class MQTT_Subscription {
+       integer  sessionIdx
+       MQTT_v3_1_1_Subscribe  request
+       MQTT_Subscription_State state
+       f_EPTF_MQTT_subscription_fromSession(inout EPTF_MQTT_PDU p_msg, in integer p_subIdx)
+       f_EPTF_MQTT_subscription_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_subIdx)
+       f_EPTF_MQTT_subscription_setState(in integer p_subIdx, in MQTT_Subscription_State p_nextState)
+       f_EPTF_MQTT_subscription_remove(in integer p_subIdx)
+     }
+  
+     class MQTT_Publish_DB {
+       EPTF_FreeBusyQueue     queue
+       MQTT_Publish_List      data
+       integer                hashRef
+       f_EPTF_MQTT_publishDB_init()
+       f_EPTF_MQTT_publishDB_add(in MQTT_Publish p_pub)
+       f_EPTF_MQTT_publishDB_lookUp(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_publishDB_get(in integer p_idx, inout MQTT_Publish p_pub)
+       f_EPTF_MQTT_publishDB_check(in integer p_idx)
+       f_EPTF_MQTT_publishDB_remove(in integer p_idx)
+       f_EPTF_MQTT_publishDB_packetIdHash(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_publishDB_cleanUp()
+     }
+     MQTT_Publish_DB "1" --> "*\n.data[]" MQTT_Publish
+  
+     class MQTT_Publish {
+       integer sessionIdx
+       integer packetId
+       integer watchdogTimer
+       MQTT_Publish_Side side
+       MQTT_Publish_State state
+       f_EPTF_MQTT_publish_fromSession(inout EPTF_MQTT_PDU p_msg, in integer p_pubIdx)
+       f_EPTF_MQTT_publish_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_pubIdx)
+       f_EPTF_MQTT_publish_watchdog(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex)
+       f_EPTF_MQTT_publish_startT_watchdog(in integer pl_pIdx, in float pl_time)
+       f_EPTF_MQTT_publish_cancelT_watchdog(in integer pl_publishIdx)
+       f_EPTF_MQTT_publish_setState(in integer p_pubIdx, in MQTT_Publish_State p_nextState)
+       f_EPTF_MQTT_publish_remove(in integer p_pubIdx)
+     }
+     
+   @enduml
+  ******************************************************************/
+
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Template
+  //
+  //  Purpose:
+  //    Grouping a <MQTT_v3_1_1_ReqResp> with an id
+  //
+  //  Elements:
+  //    id  - *charstring* - identifier
+  //    msg  - <MQTT_v3_1_1_ReqResp> - MQTT PDU
+  ///////////////////////////////////////////////////////////
   type record MQTT_Template
   {
     charstring id,
     MQTT_v3_1_1_ReqResp msg
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Template_List
+  //
+  //  Purpose:
+  //    List of <MQTT_Template>
+  ///////////////////////////////////////////////////////////
   type record of MQTT_Template MQTT_Template_List;
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Template_DB.jpg
+     class MQTT_Template_DB {
+       EPTF_FreeBusyQueue queue
+       MQTT_Template_List data
+       integer hashRef
+       f_EPTF_MQTT_templateDB_init()
+       f_EPTF_MQTT_templateDB_add(in MQTT_Template p_template)
+       f_EPTF_MQTT_templateDB_lookUp(in charstring p_id)
+       f_EPTF_MQTT_templateDB_get(in integer p_idx, inout Socket MQTT_v3_1_1_ReqResp p_pdu)
+       f_EPTF_MQTT_templateDB_cleanUp()
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Template_DB
+  //
+  //  Purpose:
+  //    Storing <MQTT_Template> instances
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Template_DB.jpg)
+  //
+  //  Elements:
+  //    data  - <MQTT_Template_List> - elements
+  //    hashRef  - charstring2int hash reference
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_templateDB_init> ()
+  //    - <f_EPTF_MQTT_templateDB_add> (in <MQTT_Template> p_template)
+  //    - <f_EPTF_MQTT_templateDB_lookUp> (in *charstring* p_id)
+  //    - <f_EPTF_MQTT_templateDB_get> (in *integer* p_idx, inout <MQTT_v3_1_1_ReqResp> p_pdu)
+  //    - <f_EPTF_MQTT_templateDB_cleanUp> ()
+  ///////////////////////////////////////////////////////////
   type record MQTT_Template_DB
   {
     MQTT_Template_List data,
     integer hashRef
   }
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Session.jpg
+     class MQTT_Session {
+       integer eIdx
+       integer fsmIdx
+       integer localAddrIdx
+       integer remoteAddrIdx
+       charstring clientId
+       float keepAliveTime
+       integer nextPacketId,
+       integer[] subscriptionRefs
+       integer[] publishRefs
+       integer keepaliveTimer
+       boolean reportPingResponse
+       boolean reportPublishResponse
+       MQTT_Session_State state
+       f_EPTF_MQTT_session_fromApp(inout EPTF_MQTT_PDU p_msg, in integer p_sIdx)
+       f_EPTF_MQTT_session_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_sIdx)
+       f_EPTF_MQTT_session_keepalive(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex)
+       f_EPTF_MQTT_session_startT_keepalive(in integer pl_sIdx, in float pl_time)
+       f_EPTF_MQTT_session_cancelT_keepalive(in integer pl_sessionIdx)
+       f_EPTF_MQTT_session_getNextPacketId(in MQTT_StepCtx p_ctx)
+       f_EPTF_MQTT_session_setState(in integer p_sessionIdx, in MQTT_Session_State p_nextState)
+       f_EPTF_MQTT_session_send(in integer p_sessionIdx, inout EPTF_MQTT_PDU p_msg)
+       f_EPTF_MQTT_session_registerSubscription(in integer p_sessionIdx, in integer p_subIdx)
+       f_EPTF_MQTT_session_deregisterSubscription(in integer p_sessionIdx, in integer p_subIdx)
+       f_EPTF_MQTT_session_registerPublish(in integer p_sessionIdx, in integer p_pubIdx)
+       f_EPTF_MQTT_session_deregisterPublish(in integer p_sessionIdx, in integer p_pubIdx)
+       f_EPTF_MQTT_session_remove(in integer p_sessionIdx)
+     }
+   @enduml
+  ******************************************************************/
+
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Session
+  //
+  //  Purpose:
+  //    Models and MQTT session
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Session.jpg)
+  //
+  // FSM Diagram of a MQTT session:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Session.jpg)
+  //
+  //  Elements:
+  //    eIdx  - *integer* - pointer to the entity that owns the session
+  //    fsmIdx - *integer* - pointer to the fsm that owns the session
+  //    localAddressIdx  - *integer* - pointer to the local address in *v_MQTT_addressDB*
+  //    remoteAddressIdx  - *integer* - pointer to the remote address in *v_MQTT_addressDB*
+  //    clientId - *charstring* - the client ID used in the session
+  //    keepAliveTime - *float* - timer used for sending keep alive messages
+  //    nextPacketId - *integer* - id used for the next packet
+  //    subscriptionRefs - <EPTF_IntegerList> - pointer to subscriptions in *v_MQTT_subscriptionDB* <MQTT_Subscription_DB>
+  //    publishRefs -  <EPTF_IntegerList> - pointer to publications in *v_MQTT_publishDB* <MQTT_Publish_DB>
+  //    keepaliveTimer - *integer* - reference for the keep alive timer in the scheduler
+  //    reportPingResponse  - *boolean* - enable/disable reporting of ping responses
+  //    reportPublishResponse  - *boolean* - enable/disabled reporting of publish responses
+  //    state - <MQTT_Session_State> - state of an MQTT session
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_session_fromApp> (*inout* <EPTF_MQTT_PDU> p_msg, *in integer* p_sIdx)
+  //    - <f_EPTF_MQTT_session_fromEnv> (*inout* <EPTF_MQTT_PDU> p_msg, *in integer* p_sIdx)
+  //    - <f_EPTF_MQTT_session_keepalive> (*in* <EPTF_ScheduledAction> pl_action, *in integer* pl_eventIndex)
+  //    - <f_EPTF_MQTT_session_startT_keepalive> (*in integer* pl_sIdx, *in float* pl_time)
+  //    - <f_EPTF_MQTT_session_cancelT_keepalive> (*in integer* pl_sessionIdx)
+  //    - <f_EPTF_MQTT_session_getNextPacketId> (*in* <MQTT_StepCtx> p_ctx)
+  //    - <f_EPTF_MQTT_session_setState> (*in integer* p_sessionIdx, *in* <MQTT_Session_State> p_nextState)
+  //    - <f_EPTF_MQTT_session_send> (*in integer* p_sessionIdx, *inout* <EPTF_MQTT_PDU> p_msg)
+  //    - <f_EPTF_MQTT_session_registerSubscription> (*in integer* p_sessionIdx, *in integer* p_subIdx)
+  //    - <f_EPTF_MQTT_session_deregisterSubscription> (*in integer* p_sessionIdx, *in integer* p_subIdx)
+  //    - <f_EPTF_MQTT_session_registerPublish> (*in integer* p_sessionIdx, *in integer* p_pubIdx)
+  //    - <f_EPTF_MQTT_session_deregisterPublish> (*in integer* p_sessionIdx, *in integer* p_pubIdx)
+  //    - <f_EPTF_MQTT_session_remove> (*in integer* p_sessionIdx)
+  ///////////////////////////////////////////////////////////
   type record MQTT_Session
   {
     integer 			eIdx,
@@ -70,6 +508,18 @@
     MQTT_Session_State 	state
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Enum: MQTT_Session_State
+  //
+  //  Purpose:
+  //    States of an <MQTT_Session> state machine
+  //
+  //  Elements:
+  //    - DISCONNECTED
+  //    - CONNECTING
+  //    - CONNECTED
+  //    - REMOVING
+  ///////////////////////////////////////////////////////////
   type enumerated MQTT_Session_State {
     DISCONNECTED,
     CONNECTING,
@@ -94,8 +544,58 @@
     state := DISCONNECTED
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Session_List
+  //
+  //  Purpose:
+  //    List of <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   type record of MQTT_Session MQTT_Session_List;
 
+
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Session_DB.jpg
+     class MQTT_Session_DB {
+       EPTF_FreeBusyQueue  queue
+       MQTT_Session_List   data
+       integer             hashRef
+       f_EPTF_MQTT_sessionDB_init()
+       f_EPTF_MQTT_sessionDB_add(in MQTT_Session p_session)
+       f_EPTF_MQTT_sessionDB_lookUp(in Socket p_sock)
+       f_EPTF_MQTT_sessionDB_get(in integer p_idx, inout MQTT_Session p_session)
+       f_EPTF_MQTT_sessionDB_setKey(in integer p_idx)
+       f_EPTF_MQTT_sessionDB_check(in integer p_idx)
+       f_EPTF_MQTT_sessionDB_remove(in integer p_idx)
+       f_EPTF_MQTT_sessionDB_addrHash(in Socket p_sock)
+       f_EPTF_MQTT_sessionDB_cleanUp()
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Session_DB
+  //
+  //  Purpose:
+  //    Storing <MQTT_Session> instances
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Session_DB.jpg)
+  //
+  //  Elements:
+  //    queue - <EPTF_FreeBusyQueue> - free-busy queue to provide dynamic array
+  //    data  - <MQTT_Session_List> - elements
+  //    hashRef  - str2int hash reference
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_sessionDB_init> ()
+  //    - <f_EPTF_MQTT_sessionDB_add> (in <MQTT_Session> p_session)
+  //    - <f_EPTF_MQTT_sessionDB_lookUp> (in <Socket> p_sock)
+  //    - <f_EPTF_MQTT_sessionDB_get> (in integer p_idx, inout MQTT_Session p_session)
+  //    - <f_EPTF_MQTT_sessionDB_setKey> (in integer p_idx)
+  //    - <f_EPTF_MQTT_sessionDB_check> (in integer p_idx)
+  //    - <f_EPTF_MQTT_sessionDB_remove> (in integer p_idx)
+  //    - <f_EPTF_MQTT_sessionDB_addrHash> (in <Socket> p_sock)
+  //    - <f_EPTF_MQTT_sessionDB_cleanUp> ()
+  ///////////////////////////////////////////////////////////
   type record MQTT_Session_DB
   {
     EPTF_FreeBusyQueue  queue,
@@ -103,14 +603,63 @@
     integer             hashRef
   }
 
-  // TODO: Currently only one topic per subscription is handled only!
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Subscription.jpg
+     class MQTT_Subscription {
+       integer  sessionIdx
+       MQTT_v3_1_1_Subscribe  request
+       MQTT_Subscription_State state
+       f_EPTF_MQTT_subscription_fromSession(inout EPTF_MQTT_PDU p_msg, in integer p_subIdx)
+       f_EPTF_MQTT_subscription_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_subIdx)
+       f_EPTF_MQTT_subscription_setState(in integer p_subIdx, in MQTT_Subscription_State p_nextState)
+       f_EPTF_MQTT_subscription_remove(in integer p_subIdx)
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Subscription
+  //
+  //  Purpose:
+  //    Models an MQTT subscription
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Subscription.jpg)
+  //
+  //  Elements:
+  //    sessionIdx - *integer* - the session, the subscription belongs to
+  //    request - <MQTT_v3_1_1_Subscribe> - the MQTT PDU that initialized the subscription (optional)
+  //    state - <MQTT_Subscription_State> - state of an MQTT subscription
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_subscription_fromSession>(*inout* <EPTF_MQTT_PDU> p_msg, *in integer* p_subIdx)
+  //    - <f_EPTF_MQTT_subscription_fromEnv>(*inout* <EPTF_MQTT_PDU> p_msg, *in integer* p_subIdx)
+  //    - <f_EPTF_MQTT_subscription_setState>(*in integer* p_subIdx, *in* <MQTT_Subscription_State> p_nextState)
+  //    - <f_EPTF_MQTT_subscription_remove>(*in integer* p_subIdx)
+  //
+  // FSM Diagram of a MQTT subscription:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Subscription.jpg)
+  ///////////////////////////////////////////////////////////  
   type record MQTT_Subscription
   {
 	integer					sessionIdx,
 	MQTT_v3_1_1_Subscribe	request optional,
     MQTT_Subscription_State state
   }
+  // TODO: Currently only one topic per subscription is handled only!  
 
+  ///////////////////////////////////////////////////////////
+  //  Enum: MQTT_Subscription_State
+  //
+  //  Purpose:
+  //    States of an <MQTT_Subscription> state machine
+  //
+  //  Elements:
+  //    - UNSUBSCRIBED
+  //    - SUBSCRIBING
+  //    - SUBSCRIBED
+  //    - UNSUBSCRIBING
+  //    - REMOVING
+  ///////////////////////////////////////////////////////////
   type enumerated MQTT_Subscription_State {
     UNSUBSCRIBED,
     SUBSCRIBING,
@@ -126,8 +675,63 @@
     state := UNSUBSCRIBED
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Subscription_List
+  //
+  //  Purpose:
+  //    List of <MQTT_Subscription>
+  ///////////////////////////////////////////////////////////
   type record of MQTT_Subscription MQTT_Subscription_List;
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Subscription_DB.jpg
+     class MQTT_Subscription_DB {
+       EPTF_FreeBusyQueue     queue
+       MQTT_Subscription_List data
+       integer                hashRef
+       f_EPTF_MQTT_subscriptionDB_init()
+       f_EPTF_MQTT_subscriptionDB_add(in MQTT_Subscription p_sub)
+       f_EPTF_MQTT_subscriptionDB_setKey_packetId(in integer p_idx, in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_removeKey_packetId(in integer p_idx, in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_lookUp_packetId(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_lookUp_topicName(in integer p_sessionIdx, in charstring p_topicName)
+       f_EPTF_MQTT_subscriptionDB_get(in integer p_idx, inout MQTT_Subscription p_sub)
+       f_EPTF_MQTT_subscriptionDB_check(in integer p_idx)
+       f_EPTF_MQTT_subscriptionDB_remove(in integer p_idx)
+       f_EPTF_MQTT_subscriptionDB_packetIdHash(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_subscriptionDB_topicHash(in integer p_sessionIdx, in charstring p_topic)
+       f_EPTF_MQTT_subscriptionDB_cleanUp()
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Subscription_DB
+  //
+  //  Purpose:
+  //    Storing <MQTT_Subscription> instances
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Subscription_DB.jpg)
+  //
+  //  Elements:
+  //    queue - <EPTF_FreeBusyQueue> - free-busy queue to provide dynamic array
+  //    data  - <MQTT_Subscription_List> - elements
+  //    hashRef  - str2int hash reference
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_subscriptionDB_init> ()
+  //    - <f_EPTF_MQTT_subscriptionDB_add> (*in* <MQTT_Subscription> p_sub)
+  //    - <f_EPTF_MQTT_subscriptionDB_setKey_packetId> (*in integer* p_idx, *in integer* p_sessionIdx, *in integer* p_packetId)
+  //    - <f_EPTF_MQTT_subscriptionDB_removeKey_packetId> (*in integer* p_idx, *in integer* p_sessionIdx, *in integer* p_packetId)
+  //    - <f_EPTF_MQTT_subscriptionDB_lookUp_packetId> (*in integer* p_sessionIdx, *in integer* p_packetId)
+  //    - <f_EPTF_MQTT_subscriptionDB_lookUp_topicName> (*in integer* p_sessionIdx, *in charstring* p_topicName)
+  //    - <f_EPTF_MQTT_subscriptionDB_get> (*in integer* p_idx, *inout* <MQTT_Subscription> p_sub)
+  //    - <f_EPTF_MQTT_subscriptionDB_check> (*in integer* p_idx)
+  //    - <f_EPTF_MQTT_subscriptionDB_remove> (*in integer* p_idx)
+  //    - <f_EPTF_MQTT_subscriptionDB_packetIdHash> (*in integer* p_sessionIdx, *in integer* p_packetId)
+  //    - <f_EPTF_MQTT_subscriptionDB_topicHash> (*in integer* p_sessionIdx, *in charstring* p_topic)
+  //    - <f_EPTF_MQTT_subscriptionDB_cleanUp> ()
+  ///////////////////////////////////////////////////////////
   type record MQTT_Subscription_DB
   {
     EPTF_FreeBusyQueue  	queue,
@@ -135,6 +739,53 @@
     integer             	hashRef // sessionIdx+packetId or sessionIdx+topicName
   }
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Publish.jpg
+     class MQTT_Publish {
+       integer sessionIdx
+       integer packetId
+       integer watchdogTimer
+       MQTT_Publish_Side side
+       MQTT_Publish_State state
+       f_EPTF_MQTT_publish_fromSession(inout EPTF_MQTT_PDU p_msg, in integer p_pubIdx)
+       f_EPTF_MQTT_publish_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_pubIdx)
+       f_EPTF_MQTT_publish_watchdog(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex)
+       f_EPTF_MQTT_publish_startT_watchdog(in integer pl_pIdx, in float pl_time)
+       f_EPTF_MQTT_publish_cancelT_watchdog(in integer pl_publishIdx)
+       f_EPTF_MQTT_publish_setState(in integer p_pubIdx, in MQTT_Publish_State p_nextState)
+       f_EPTF_MQTT_publish_remove(in integer p_pubIdx)
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Publish
+  //
+  //  Purpose:
+  //    Models an MQTT publish
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Publish.jpg)
+  //
+  //  Elements:
+  //    sessionIdx - *integer* - the session, the subscription belongs to
+  //    packetId - *integer* - packet id
+  //    watchdogTimer - *integer* - reference to the watchdog timer in the scheduler
+  //    side - <MQTT_Publish_Side> - originating or terminating side of the publication
+  //    state - <MQTT_Publish_State> - state of an MQTT publish
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_publish_fromSession> (*inout* <EPTF_MQTT_PDU> p_msg, *in integer* p_pubIdx)
+  //    - <f_EPTF_MQTT_publish_fromEnv> (*inout* <EPTF_MQTT_PDU> p_msg, *in integer* p_pubIdx)
+  //    - <f_EPTF_MQTT_publish_watchdog> (*in* <EPTF_ScheduledAction> pl_action, *in integer* pl_eventIndex)
+  //    - <f_EPTF_MQTT_publish_startT_watchdog> (*in integer* pl_pIdx, *in float* pl_time)
+  //    - <f_EPTF_MQTT_publish_cancelT_watchdog> (*in integer* pl_publishIdx)
+  //    - <f_EPTF_MQTT_publish_setState> (*in integer* p_pubIdx, *in* <MQTT_Publish_State> p_nextState)
+  //    - <f_EPTF_MQTT_publish_remove> (*in integer* p_pubIdx)
+  //
+  // FSM Diagram of a MQTT publish:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Publish_qos1.jpg)
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Publish_qos2.jpg)
+  /////////////////////////////////////////////////////////// 
   type record MQTT_Publish
   {
 	integer					sessionIdx,
@@ -155,12 +806,34 @@
     state := { created := true }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Enum: MQTT_Publish_Side
+  //
+  //  Purpose:
+  //    Side of an <MQTT_Publish>
+  //
+  //  Elements:
+  //    - ORIG
+  //    - TERM
+  ///////////////////////////////////////////////////////////
   type enumerated MQTT_Publish_Side
   {
     ORIG,
     TERM
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Publish_State
+  //
+  //  Purpose:
+  //    State of an <MQTT_Publish>
+  //
+  //  Elements:
+  //    qos1 - <MQTT_PublishQos1_State> - QoS1 state
+  //    qos2 - <MQTT_PublishQos2_State> - QoS2 state
+  //    created - *boolean* - just created
+  //    removing - *boolean* - currently removing
+  ///////////////////////////////////////////////////////////
   type union MQTT_Publish_State
   {
     MQTT_PublishQos1_State qos1,
@@ -169,6 +842,17 @@
     boolean removing
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Enum: MQTT_PublishQos1_State
+  //
+  //  Purpose:
+  //    Qos1 state of an <MQTT_Publish_State>
+  //
+  //  Elements:
+  //    - CREATED
+  //    - PUBLISHED
+  //    - ACKNOWLEDGED
+  ///////////////////////////////////////////////////////////
   type enumerated MQTT_PublishQos1_State
   {
     CREATED,
@@ -176,6 +860,19 @@
     ACKNOWLEDGED
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Enum: MQTT_PublishQos2_State
+  //
+  //  Purpose:
+  //    Qos2 state of an <MQTT_Publish_State>
+  //
+  //  Elements:
+  //    - CREATED
+  //    - PUBLISHED
+  //    - RECEIVED
+  //    - RELEASED
+  //    - COMPLETE
+  ///////////////////////////////////////////////////////////
   type enumerated MQTT_PublishQos2_State
   {
     CREATED,
@@ -185,8 +882,55 @@
     COMPLETE
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Publish_List
+  //
+  //  Purpose:
+  //    List of <MQTT_Publish>
+  ///////////////////////////////////////////////////////////
   type record of MQTT_Publish MQTT_Publish_List;
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Publish_DB.jpg
+     class MQTT_Publish_DB {
+       EPTF_FreeBusyQueue     queue
+       MQTT_Publish_List      data
+       integer                hashRef
+       f_EPTF_MQTT_publishDB_init()
+       f_EPTF_MQTT_publishDB_add(in MQTT_Publish p_pub)
+       f_EPTF_MQTT_publishDB_lookUp(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_publishDB_get(in integer p_idx, inout MQTT_Publish p_pub)
+       f_EPTF_MQTT_publishDB_check(in integer p_idx)
+       f_EPTF_MQTT_publishDB_remove(in integer p_idx)
+       f_EPTF_MQTT_publishDB_packetIdHash(in integer p_sessionIdx, in integer p_packetId)
+       f_EPTF_MQTT_publishDB_cleanUp()
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Publish_DB
+  //
+  //  Purpose:
+  //    Storing <MQTT_Publish> instances
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Publish_DB.jpg)
+  //
+  //  Elements:
+  //    queue - <EPTF_FreeBusyQueue> - free-busy queue to provide dynamic array
+  //    data  - <MQTT_Publish_List> - elements
+  //    hashRef  - str2int hash reference
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_publishDB_init> ()
+  //    - <f_EPTF_MQTT_publishDB_add> (*in* <MQTT_Publish> p_pub)
+  //    - <f_EPTF_MQTT_publishDB_lookUp> (*in integer* p_sessionIdx, *in integer* p_packetId)
+  //    - <f_EPTF_MQTT_publishDB_get> (*in integer* p_idx, *inout* <MQTT_Publish> p_pub)
+  //    - <f_EPTF_MQTT_publishDB_check> (*in integer* p_idx)
+  //    - <f_EPTF_MQTT_publishDB_remove> (*in integer* p_idx)
+  //    - <f_EPTF_MQTT_publishDB_packetIdHash> (*in integer* p_sessionIdx, *in integer* p_packetId)
+  //    - <f_EPTF_MQTT_publishDB_cleanUp> ()
+  ///////////////////////////////////////////////////////////
   type record MQTT_Publish_DB
   {
     EPTF_FreeBusyQueue  	queue,
@@ -194,6 +938,17 @@
     integer             	hashRef // sessionIdx+packetId
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_StepCtx
+  //
+  //  Purpose:
+  //    Type that stores the most important pointers
+  //
+  //  Elements:
+  //    eIdx  - *integer* - entity index
+  //    fsmIdx - *integer* - fsm index
+  //    sessionIdx - *integer* - MQTT session index <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   type record MQTT_StepCtx
   {
     integer eIdx,
@@ -208,8 +963,51 @@
 	sessionIdx := -1
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Address_List
+  //
+  //  Purpose:
+  //    List of <Socket>
+  ///////////////////////////////////////////////////////////
   type record of Socket MQTT_Address_List;
 
+ /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.MQTT_Address_DB.jpg
+     class MQTT_Address_DB {
+       EPTF_FreeBusyQueue     queue
+       MQTT_Address_List      data
+       integer                hashRef
+       f_EPTF_MQTT_addressDB_init()
+       f_EPTF_MQTT_addressDB_add(in Socket p_addr, inout integer p_idx)
+       f_EPTF_MQTT_addressDB_lookUp(in Socket p_sock)
+       f_EPTF_MQTT_addressDB_get(inout Socket p_addr, in integer p_idx)
+       f_EPTF_MQTT_addressDB_Socket2String(Socket p_sock)
+       f_EPTF_MQTT_addressDB_cleanUp()
+     }
+   @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Type: MQTT_Address_DB
+  //
+  //  Purpose:
+  //    Storing <Socket> instances
+  //
+  //  Class:
+  //    (see EPTF_MQTT_LGen_Definitions.MQTT_Address_DB.jpg)
+  //
+  //  Elements:
+  //    queue - <EPTF_FreeBusyQueue> - free-busy queue to provide dynamic array
+  //    data  - <MQTT_Address_List> - elements
+  //    hashRef  - str2int hash reference
+  //
+  //  Related Functions:
+  //    - <f_EPTF_MQTT_addressDB_init> ()
+  //    - <f_EPTF_MQTT_addressDB_add> (*in* <Socket> p_addr, *inout integer* p_idx)
+  //    - <f_EPTF_MQTT_addressDB_lookUp> (*in* <Socket> p_sock)
+  //    - <f_EPTF_MQTT_addressDB_get> (*inout* <Socket> p_addr, *in integer* p_idx)
+  //    - <f_EPTF_MQTT_addressDB_Socket2String> (<Socket> p_sock)
+  //    - <f_EPTF_MQTT_addressDB_cleanUp> ()
+  ///////////////////////////////////////////////////////////
   type record MQTT_Address_DB
   {
     EPTF_FreeBusyQueue queue,
@@ -217,8 +1015,126 @@
     integer hashRef
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: fcb_EPTF_MQTT_messageReceived
+  //
+  //  Purpose:
+  //    Call-back function type for reporting received MQTT messages
+  //
+  //  Elements:
+  //    pl_message  - *in* <EPTF_MQTT_PDU> - received MQTT message
+  ///////////////////////////////////////////////////////////  
   type function fcb_EPTF_MQTT_messageReceived(in EPTF_MQTT_PDU pl_message) runs on self;
 
+
+
+
+  /*****************************************************************
+   @startuml EPTF_MQTT_LGen_Definitions.EPTF_MQTT_LGen_CT.jpg
+     class EPTF_MQTT_LGen_CT {
+       boolean v_MQTT_initialized
+       integer v_MQTT_bIdx
+       integer v_MQTT_loggingMaskId
+       MQTT_Address_DB      v_MQTT_addressDB
+       MQTT_Template_DB     v_MQTT_templateDB
+       MQTT_Session_DB      v_MQTT_sessionDB
+       MQTT_Subscription_DB v_MQTT_subscriptionDB
+       MQTT_Publish_DB v_MQTT_publishDB
+       MQTT_StepCtx    v_MQTT_ctx
+       MQTT_Session    v_MQTT_session
+       MQTT_Subscription v_MQTT_subscription
+       MQTT_Publish      v_MQTT_publish
+       EPTF_MQTT_PDU     v_MQTT_msgToProcess
+       EPTF_MQTT_PDU     v_MQTT_msgToSend
+       fcb_EPTF_MQTT_messageReceived vf_MQTT_msgReceived
+       f_EPTF_MQTT_LGen_init(in charstring pl_name)
+       f_EPTF_MQTT_LGen_initLogging()
+       f_MQTT_cleanUp()
+       f_MQTT_eCtxBind(in integer pl_eIdx)
+       f_MQTT_eCtxUnbind(in integer pl_eIdx)
+       f_MQTT_eCtxReset(in integer pl_eIdx)
+       f_EPTF_MQTT_declareEvents()
+       f_EPTF_MQTT_declareSteps()
+       f_EPTF_MQTT_LGen_receiveMessage(in EPTF_MQTT_PDU pl_message)
+       f_EPTF_MQTT_LGen_receiveEvent(in ASP_Event p_event)
+       f_EPTF_MQTT_LGen_transportApiResponse(in EPTF_MQTT_Transport_Response pl_rsp)
+       f_EPTF_MQTT_LGen_send(inout EPTF_MQTT_PDU p_msg)
+       f_EPTF_MQTT_stack_fromApp(inout EPTF_MQTT_PDU p_msg, in MQTT_StepCtx p_ctx)
+       f_EPTF_MQTT_stack_fromEnv(inout EPTF_MQTT_PDU p_msg)
+       f_EPTF_MQTT_isFsmInitialized(in integer pl_eIdx, in integer pl_fsmIdx, inout integer pl_sessionIdx)
+       f_EPTF_MQTT_Logging_VERBOSE(in @lazy charstring pl_message)
+       f_EPTF_MQTT_Logging_DEBUG(in @lazy charstring pl_message)
+       f_EPTF_MQTT_Logging_WARNING(in @lazy charstring pl_message)
+       f_EPTF_MQTT_Logging_ERROR(in @lazy charstring pl_message)
+       f_EPTF_MQTT_dispatchEvent(in integer pl_eventIdx, in integer pl_eIdx, in integer pl_fsmCtx, in EPTF_IntegerList pl_reportedArgs)
+     }
+   @enduml
+  *****************************************************************/
+  ///////////////////////////////////////////////////////////
+  // Type: EPTF_MQTT_LGen_CT
+  //
+  // Purpose:
+  //   MQTT load generator component
+  //
+  // Class:
+  //   (see EPTF_MQTT_LGen_Definitions.EPTF_MQTT_LGen_CT.jpg)
+  //
+  // Extensions:
+  //  - <EPTF_LGenBase_CT>
+  //  - <EPTF_MQTT_Transport_User_CT>
+  //  - <EPTF_Logging_CT>
+  //
+  // Ports:
+  //   -
+  //
+  // Timers:
+  //   -
+  //
+  // Variables:
+  //   v_MQTT_initialized  - *boolean* - Flag to indicate that if init function was already called
+  //   v_MQTT_bIdx  - *integer* - Name of the NAS_EPS LGen component
+  //   v_MQTT_loggingMaskId - *integer* - logging mask id
+  //
+  //   v_MQTT_ctx - <MQTT_StepCtx> - collection of the most important pointers
+  //   v_MQTT_session - <MQTT_Session> - temporary variable for a <MQTT_Session>
+  //   v_MQTT_subscription - <MQTT_Subscription> - temporary variable for a <MQTT_Subscription>
+  //   v_MQTT_publish - <MQTT_Publish> - temporary variable for a <MQTT_Publish>
+  //
+  //   v_MQTT_msgToProcess - <EPTF_MQTT_PDU> - message to process
+  //   v_MQTT_msgToSend - <EPTF_MQTT_PDU> - message to send
+  //
+  //
+  //   vf_MQTT_msgReceived - <fcb_EPTF_MQTT_messageReceived> - Function hook for reporting received messages
+  // 
+  // Instance databases:
+  //   v_MQTT_addressDB - <MQTT_Address_DB> - address database of <Socket>
+  //   v_MQTT_templateDB - <MQTT_Template_DB> - template database <MQTT_Template>
+  //   v_MQTT_sessionDB - <MQTT_Session_DB> - MQTT session database of <MQTT_Session>
+  //   v_MQTT_subscriptionDB - <MQTT_Subscription_DB> - MQTT subscription database of <MQTT_Subscription>
+  //   v_MQTT_publishDB - <MQTT_Publish_DB> - MQTT publish database of <MQTT_Session>
+  //
+  // Related Functions:
+  //   - <f_EPTF_MQTT_LGen_init> (*in charstring* pl_name)
+  //   - <f_EPTF_MQTT_LGen_initLogging> ()
+  //   - <f_MQTT_cleanUp> ()
+  //   - <f_MQTT_eCtxBind> (*in integer* pl_eIdx)
+  //   - <f_MQTT_eCtxUnbind> (*in integer* pl_eIdx)
+  //   - <f_MQTT_eCtxReset> (*in integer* pl_eIdx)
+  //   - <f_EPTF_MQTT_declareEvents> ()
+  //   - <f_EPTF_MQTT_declareSteps> ()
+  //   - <f_EPTF_MQTT_LGen_receiveMessage> (*in* <EPTF_MQTT_PDU> pl_message)
+  //   - <f_EPTF_MQTT_LGen_receiveEvent> (*in* <ASP_Event> p_event)
+  //   - <f_EPTF_MQTT_LGen_transportApiResponse> (*in* <EPTF_MQTT_Transport_Response> pl_rsp)
+  //   - <f_EPTF_MQTT_LGen_send> (*inout* <EPTF_MQTT_PDU> p_msg)
+  //   - <f_EPTF_MQTT_stack_fromApp> (*inout* <EPTF_MQTT_PDU> p_msg, *in* <MQTT_StepCtx> p_ctx)
+  //   - <f_EPTF_MQTT_stack_fromEnv> (*inout* <EPTF_MQTT_PDU> p_msg)
+  //   - <f_EPTF_MQTT_isFsmInitialized> (*in integer* pl_eIdx, *in integer* pl_fsmIdx, *inout integer* pl_sessionIdx)
+  //   - <f_EPTF_MQTT_Logging_VERBOSE> (*in @lazy charstring* pl_message)
+  //   - <f_EPTF_MQTT_Logging_DEBUG> (*in @lazy charstring* pl_message)
+  //   - <f_EPTF_MQTT_Logging_WARNING> (*in @lazy charstring* pl_message)
+  //   - <f_EPTF_MQTT_Logging_ERROR> (*in @lazy charstring* pl_message)
+  //   - <f_EPTF_MQTT_dispatchEvent> (*in integer* pl_eventIdx, *in integer* pl_eIdx, *in integer* pl_fsmCtx, *in* <EPTF_IntegerList> pl_reportedArgs)
+  ///////////////////////////////////////////////////////////
   type component EPTF_MQTT_LGen_CT extends EPTF_MQTT_Transport_User_CT, EPTF_LGenBase_CT, EPTF_Logging_CT
   {
     var boolean v_MQTT_initialized := false;
@@ -248,117 +1164,724 @@
 
   // Events
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_transportSucc
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT transport succesful indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_transportSucc := 0;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_transportSucc
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT transport succesful indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_transportSucc := "MQTT transport: succ rsp";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_transportFail
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT transport fail indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_transportFail := 1;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_transportFail
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT transport fail indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_transportFail := "MQTT transport: fail rsp";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_transportClosed
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT transport closed indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_transportClosed := 2;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_transportClosed
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT transport closed indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_transportClosed := "MQTT transport: connection closed";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_CONNACK_Accepted
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT CONNACK accepted indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_CONNACK_Accepted := 3;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_CONNACK_Accepted
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT CONNACK accepted indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_CONNACK_Accepted := "MQTT rsp: CONNACK Accepted";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_CONNACK_Refused
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT CONNACK refused indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_CONNACK_Refused := 4;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_CONNACK_Refused
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT CONNACK refused indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_CONNACK_Refused := "MQTT rsp: CONNACK Refused";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_SUBACK_Accepted
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT SUBACK accepted indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_SUBACK_Accepted := 5;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_SUBACK_Accepted
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT SUBACK accepted indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_SUBACK_Accepted := "MQTT rsp: SUBACK Accepted";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_SUBACK_Refused
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT SUBACK refused indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_SUBACK_Refused := 6;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_SUBACK_Refused
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT SUBACK refused indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_SUBACK_Refused := "MQTT rsp: SUBACK Refused";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_UNSUBACK
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT UNSUBACK indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_UNSUBACK := 7;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_UNSUBACK
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT UNSUBACK indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_UNSUBACK := "MQTT rsp: UNSUBACK";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PUBLISH
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PUBLISH indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PUBLISH := 8;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PUBLISH
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PUBLISH indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PUBLISH := "MQTT req: PUBLISH";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PING_Request
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PING request indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PING_Request := 9;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PING_Request
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PING request indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PING_Request := "MQTT req: PING";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PING_Response
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PING response indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PING_Response := 10;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PING_Response
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PING response indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PING_Response := "MQTT rsp: PING";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PUBACK
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PUBACK indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PUBACK := 11;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PUBACK
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PUBACK indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PUBACK := "MQTT rsp: PUBACK";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PUBREC
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PUBREC indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PUBREC := 12;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PUBREC
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PUBREC indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PUBREC := "MQTT rsp: PUBREC";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PUBREL
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PUBREL indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PUBREL := 13;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PUBREL
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PUBREL indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PUBREL := "MQTT req: PUBREL";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PUBCOMP
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PUBCOMP indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PUBCOMP := 14;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PUBCOMP
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PUBCOMP indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PUBCOMP := "MQTT rsp: PUBCOMP";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventIdx_PUBLISH_Timeout
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT PUBLISH timeout indication
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_eventIdx_PUBLISH_Timeout := 15;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_eventName_PUBLISH_Timeout
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT PUBLISH timeout indication
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_eventName_PUBLISH_Timeout := "MQTT timeout: PUBLISH Timeout";
 
 
   // Steps
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_init
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT init test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_init>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_init := 0;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_init
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT init test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_init>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_init := "MQTT Applib: init";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_cleanUp
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT clean up test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_cleanUp>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_cleanUp := 1;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_cleanUp
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT clean up test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_cleanUp>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_cleanUp := "MQTT Applib: cleanUp";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setLocalAddress_byVars
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set local address  by variables test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setLocalAddress_byVars>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setLocalAddress_byVars := 2;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setLocalAddress_byVars
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set local address  by variables test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setLocalAddress_byVars>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setLocalAddress_byVars := "MQTT Applib: setLocalAddress_byVars";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setRemoteAddress_byVars
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set remote address  by variables test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setRemoteAddress_byVars>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setRemoteAddress_byVars := 3;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setRemoteAddress_byVars
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set remote address  by variables test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setRemoteAddress_byVars>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setRemoteAddress_byVars := "MQTT Applib: setRemoteAddress_byVars";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_transportConnect
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT transport connect test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_transportConnect>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_transportConnect := 4;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_transportConnect
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT transport connect test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_transportConnect>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_transportConnect := "MQTT Applib: transportConnect";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_transportClose
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT transport close test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_transportClose>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_transportClose := 5;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_transportClose
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT transport close test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_transportClose>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_transportClose := "MQTT Applib: transportClose";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_startListening
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT start listening test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_startListening>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_startListening := 6;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_startListening
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT start listening test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_startListening>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_startListening := "MQTT Applib: startListening";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_loadTemplate_byIntIdx
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT load template by integer idx pointer test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_loadTemplate_byIntIdx>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_loadTemplate_byIntIdx := 7;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_loadTemplate_byIntIdx
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT load template by integer idx pointer test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_loadTemplate_byIntIdx>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_loadTemplate_byIntIdx := "MQTT Applib: loadTemplate_byIntIdx";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_loadTemplate_byStringId
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT load template by string id test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_loadTemplate_byStringId>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_loadTemplate_byStringId := 8;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_loadTemplate_byStringId
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT load template by string id test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_loadTemplate_byStringId>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_loadTemplate_byStringId := "MQTT Applib: loadTemplate_byStringId";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_send
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT send test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_send>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_send := 9;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_send
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT send test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_send>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_send := "MQTT Applib: send";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setTopic_stringParam
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set topic by string parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_stringParam>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setTopic_stringParam := 10;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setTopic_stringParam
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set topic by string parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_stringParam>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setTopic_stringParam := "MQTT Applib: setTopic_stringParam";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setTopic_add_stringParam
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set topic by adding a string test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_add_stringParam>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setTopic_add_stringParam := 11;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setTopic_add_stringParam
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set topic by adding a string test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_add_stringParam>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setTopic_add_stringParam := "MQTT Applib: setTopic_add_stringParam";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setTopic_add_varParams
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set topic by adding variable parameters test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_add_varParams>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setTopic_add_varParams := 12;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setTopic_add_varParams
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set topic by adding variable parameters test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_add_varParams>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setTopic_add_varParams := "MQTT Applib: setTopic_add_varParams";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setTopic_add_clientId
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set topic by adding the client id test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_add_clientId>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setTopic_add_clientId := 13;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setTopic_add_clientId
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set topic by adding the client id test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setTopic_add_clientId>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setTopic_add_clientId := "MQTT Applib: setTopic_add_clientId";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setQos_intParam
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set QoS using integer parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setQos_intParam>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setQos_intParam := 14;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setQos_intParam
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set QoS using integer parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setQos_intParam>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setQos_intParam := "MQTT Applib: setQos_intParam";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setPublishMessage_stringParam
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set publish message using a string parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_stringParam>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setPublishMessage_stringParam := 15;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setPublishMessage_stringParam
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set publish message using a string parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_stringParam>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setPublishMessage_stringParam := "MQTT Applib: setPublishMessage_stringParam";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setPublishMessage_add_stringParam
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set publish by adding a string parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_add_stringParam>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setPublishMessage_add_stringParam := 16;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setPublishMessage_add_stringParam
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set publish by adding a string parameter test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_add_stringParam>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setPublishMessage_add_stringParam := "MQTT Applib: setPublishMessage_add_stringParam";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setPublishMessage_add_varParams
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set publish by adding variable parameters test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_add_varParams>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setPublishMessage_add_varParams := 17;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setPublishMessage_add_varParams
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set publish by adding variable parameters test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_add_varParams>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setPublishMessage_add_varParams := "MQTT Applib: setPublishMessage_add_varParams";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_setPublishMessage_add_clientId
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT set publish by adding the client id test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_add_clientId>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_setPublishMessage_add_clientId := 18;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_setPublishMessage_add_clientId
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT set publish by adding the client id test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_setPublishMessage_add_clientId>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_setPublishMessage_add_clientId := "MQTT Applib: setPublishMessage_add_clientId";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_reportPingResponse
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT enabling/disabling the reporting of a ping response test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_reportPingResponse>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_reportPingResponse := 19;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_reportPingResponse
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT enabling/disabling the reporting of a ping response test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_reportPingResponse>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_reportPingResponse := "MQTT Applib: reportPingResponse";
 
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepIdx_reportPublishResponse
+  //
+  //  Purpose:
+  //    Integer constant for the MQTT enabling/disabling the reporting of a publish response test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_reportPublishResponse>
+  ///////////////////////////////////////////////////////////
   const integer c_MQTT_stepIdx_reportPublishResponse := 20;
+
+  ///////////////////////////////////////////////////////////
+  //  const: c_MQTT_stepName_reportPublishResponse
+  //
+  //  Purpose:
+  //    Charstring constant for the MQTT enabling/disabling the reporting of a publish response test step
+  //
+  //  Related Function:
+  //    - <f_MQTT_step_reportPublishResponse>
+  ///////////////////////////////////////////////////////////
   const charstring c_MQTT_stepName_reportPublishResponse := "MQTT Applib: reportPublishResponse";
 }
diff --git a/src/EPTF_MQTT_LGen_Functions.ttcn b/src/EPTF_MQTT_LGen_Functions.ttcn
index 5a48041..1a21385 100644
--- a/src/EPTF_MQTT_LGen_Functions.ttcn
+++ b/src/EPTF_MQTT_LGen_Functions.ttcn
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2000-2019 Ericsson Telecom AB
+// Copyright (c) 2000-2020 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
@@ -9,11 +9,22 @@
 ///////////////////////////////////////////////////////////////////////////////
 //  File:               EPTF_MQTT_LocalTransport_Definitions.ttcn
 //  Description:
-//  Rev:                R1A
+//  Rev:                <RnXnn>
 //  Prodnr:             CNL 113 860
-//  Updated:            2017-09-01
+//  Updated:            2020-01-07
 //  Contact:            http://ttcn.ericsson.se
 ///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+//  Module: EPTF_MQTT_LGen_Functions
+// 
+//  Purpose:
+//    This module contains the functions of the MQTT load generator component
+//
+//  See also:
+//    <EPTF_MQTT_LGen_Definitions>
+///////////////////////////////////////////////////////////////
+
 module EPTF_MQTT_LGen_Functions {
 
   import from EPTF_MQTT_LGen_Definitions all;
@@ -38,6 +49,18 @@
   import from MQTT_v3_1_1_Types all;
   import from IPL4asp_Types all;
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LGen_init
+  //
+  //  Purpose:
+  //    The main initialization function for the <EPTF_MQTT_LGen_CT> component type
+  //
+  //  Parameters:
+  //    pl_name - *in* *charstring* - the name for the component instance
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LGen_init(in charstring pl_name)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -77,6 +100,15 @@
     v_MQTT_initialized := true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LGen_initLogging
+  //
+  //  Purpose:
+  //    Initializing CLL's logging feature on the <EPTF_MQTT_LGen_CT> component type
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LGen_initLogging()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -103,6 +135,15 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_cleanUp
+  //
+  //  Purpose:
+  //    The main clean up function for the <EPTF_MQTT_LGen_CT> component type
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_cleanUp()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -117,6 +158,21 @@
     v_MQTT_initialized := false;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_eCtxBind
+  //
+  //  Purpose:
+  //    This function is called by the CLL for each entity instance created on a particular instace of <EPTF_MQTT_LGen_CT>
+  //
+  //  Parameters:
+  //    pl_eIdx - *in* *integer* - the index of the entity instance on this load generator component instance
+  //
+  //  Returns:
+  //    <EPTF_IntegerList> - The list will contain the index of the entity the context belongs to
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_eCtxBind(in integer pl_eIdx)
   runs on EPTF_MQTT_LGen_CT
   return EPTF_IntegerList
@@ -124,17 +180,50 @@
     return {pl_eIdx};
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_eCtxUnbind
+  //
+  //  Purpose:
+  //    The reverse operation of <f_MQTT_eCtxBind>. Cleans up resources reserved during <f_MQTT_eCtxBind>. Called by the CLL.
+  //
+  //  Parameters:
+  //    pl_eIdx - *in* *integer* - the index of the entity instance on this load generator component instance
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_eCtxUnbind(in integer pl_eIdx)
   runs on EPTF_MQTT_LGen_CT
   {
     if (not v_MQTT_initialized) {return;}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_eCtxReset
+  //
+  //  Purpose:
+  //    The resources reserved during <f_MQTT_eCtxBind> are reinitalized (reset). Called by the CLL. 
+  //
+  //  Parameters:
+  //    pl_eIdx - *in* *integer* - the index of the entity instance on this load generator component instance
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_eCtxReset(in integer pl_eIdx)
   runs on EPTF_MQTT_LGen_CT
   {
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_declareEvents
+  //
+  //  Purpose:
+  //    Declares the FSM events to the CLL framework implemented by <EPTF_MQTT_LGen_CT>
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_declareEvents()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -165,6 +254,15 @@
 
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_declareSteps
+  //
+  //  Purpose:
+  //    Declares the FSM steps to the CLL framework implemented by <EPTF_MQTT_LGen_CT>
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_declareSteps()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -197,6 +295,22 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LGen_receiveMessage
+  //
+  //  Purpose:
+  //    The transport layer implementation <EPTF_MQTT_Transport_Provider_CT> can report received <EPTF_MQTT_PDU> message
+  //    to the load generator layer <EPTF_MQTT_Transport_User_CT> extended by <EPTF_MQTT_LGen_CT> using this function. 
+  //
+  //  Parameters:
+  //    pl_message - *in* <EPTF_MQTT_PDU> - received message
+  //
+  //  Related Types:
+  //    - <EPTF_MQTT_LGen_CT>
+  //    - <fcb_EPTF_MQTT_Transport_receiveMessage>
+  //    - <EPTF_MQTT_Transport_Provider_CT>
+  //    - <EPTF_MQTT_Transport_User_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LGen_receiveMessage(in EPTF_MQTT_PDU pl_message)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -212,6 +326,22 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LGen_receiveEvent
+  //
+  //  Purpose:
+  //    The transport layer implementation <EPTF_MQTT_Transport_Provider_CT> can report received <ASP_Event> events
+  //    to the load generator layer <EPTF_MQTT_Transport_User_CT> extended by <EPTF_MQTT_LGen_CT> using this function. 
+  //
+  //  Parameters:
+  //    pl_message - *in* <ASP_Event> - received event
+  //
+  //  Related Types:
+  //    - <EPTF_MQTT_LGen_CT>
+  //    - <fcb_EPTF_MQTT_Transport_receiveEvent>
+  //    - <EPTF_MQTT_Transport_Provider_CT>
+  //    - <EPTF_MQTT_Transport_User_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LGen_receiveEvent(in ASP_Event p_event)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -220,6 +350,22 @@
     // TODO: connection closed handling!
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LGen_transportApiResponse
+  //
+  //  Purpose:
+  //    The transport layer implementation <EPTF_MQTT_Transport_Provider_CT> can report received <EPTF_MQTT_Transport_Response> responses
+  //    to the load generator layer <EPTF_MQTT_Transport_User_CT> extended by <EPTF_MQTT_LGen_CT> using this function. 
+  //
+  //  Parameters:
+  //    pl_rsp - *in* <EPTF_MQTT_Transport_Response> - received transport api response
+  //
+  //  Related Types:
+  //    - <EPTF_MQTT_LGen_CT>
+  //    - <fcb_EPTF_MQTT_Transport_apiResponse>
+  //    - <EPTF_MQTT_Transport_Provider_CT>
+  //    - <EPTF_MQTT_Transport_User_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LGen_transportApiResponse(in EPTF_MQTT_Transport_Response pl_rsp)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -242,12 +388,38 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LGen_send
+  //
+  //  Purpose:
+  //    This function is used to send out a message of a <EPTF_MQTT_PDU> using the registered
+  //    function <fcb_EPTF_MQTT_Transport_sendMessage> of the underlying transport layer instance.
+  //
+  //  Parameters:
+  //    p_msg - *intout* <EPTF_MQTT_PDU> - the message to be sent
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_PDU>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LGen_send(inout EPTF_MQTT_PDU p_msg)
   runs on EPTF_MQTT_LGen_CT
   {
     vf_EPTF_MQTT_Transport_send.apply(p_msg);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_init
+  //
+  //  Purpose:
+  //    Test Step to dynamically allocate and initialize the MQTT FSM context for the caller FSM. Prerequisite to call any other MQTT test step.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_init>
+  //    - <c_MQTT_stepName_init>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_init(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -271,6 +443,19 @@
     f_EPTF_LGenBase_setAppDataItemOfFsmCtx(vl_eIdx, vl_fsmIdx, v_MQTT_bIdx, c_MQTT_AppData_sessionIdx, vl_newSessionIdx);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_cleanUp
+  //
+  //  Purpose:
+  //    Test Step to free up the MQTT FSM context for the caller FSM. Frees up all allocated instances that were used by this FSM instance.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_cleanUp>
+  //    - <c_MQTT_stepName_cleanUp>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_cleanUp(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -293,8 +478,19 @@
     f_EPTF_LGenBase_setAppDataItemOfFsmCtx(vl_eIdx, vl_fsmIdx, v_MQTT_bIdx, c_MQTT_AppData_sessionIdx, -1);
   }
 
-  // 1st param: remoteHost: charstring
-  // 2nd param: remotePort: integer
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setLocalAddress_byVars
+  //
+  //  Purpose:
+  //    Test step to set the local address in the entity context.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args (1st param: remoteHost: charstring, 2nd param: remotePort: integer)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setLocalAddress_byVars>
+  //    - <c_MQTT_stepName_setLocalAddress_byVars>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setLocalAddress_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -333,8 +529,19 @@
     }
   }
 
-  // 1st param: remoteHost: charstring
-  // 2nd param: remotePort: integer
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setRemoteAddress_byVars
+  //
+  //  Purpose:
+  //    Test step to set the remote address in the FSM context.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args (1st param: remoteHost: charstring, 2nd param: remotePort: integer)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setRemoteAddress_byVars>
+  //    - <c_MQTT_stepName_setRemoteAddress_byVars>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setRemoteAddress_byVars(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -373,6 +580,27 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_startListening
+  //
+  //  Purpose:
+  //    The test step expects that a transport endpoint is set in the addressDB as a local address.
+  //    The step will initiate allocating the local address associated with the current session in the MQTT context
+  //    and call the callback function to start listening.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_startListening>
+  //    - <c_MQTT_stepName_startListening>
+  //
+  //  Related Steps:
+  //    - <f_MQTT_step_setLocalAddress_byVars>
+  //
+  //  Related Callback Function Type:
+  //    <fcb_EPTF_MQTT_Transport_apiRequest>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_startListening(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -388,6 +616,31 @@
     vf_EPTF_MQTT_Transport_apiRequest.apply(vl_req);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_transportConnect
+  //
+  //  Purpose:
+  //    The test step expects that local and remote socket adresses are set in the addressDB.
+  //    The step will initiate allocating the local and remote addresses associated with the current session in the MQTT context
+  //    and call the callback function to establish a connection.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_transportConnect>
+  //    - <c_MQTT_stepName_transportConnect>
+  //
+  //  Related Events:
+  //    - <c_MQTT_eventIdx_transportSucc>
+  //    - <c_MQTT_eventIdx_transportFail>
+  //
+  //  Related Steps:
+  //    - <f_MQTT_step_setLocalAddress_byVars>
+  //
+  //  Related Callback Function Type:
+  //    <fcb_EPTF_MQTT_Transport_apiRequest>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_transportConnect(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -404,7 +657,27 @@
     vf_EPTF_MQTT_Transport_apiRequest.apply(vl_req);
   }
 
-  // 1st param int: expectResponse (optional)
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_transportClose
+  //
+  //  Purpose:
+  //    The test step expects that a transport endpoint is set in the addressDB as a local address.
+  //    The step will call the callback function to close the connection by the local address associated with the current session in the MQTT context.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args (1st param int: expectResponse (optional))
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_transportClose>
+  //    - <c_MQTT_stepName_transportClose>
+  //
+  //  Related Steps:
+  //    - <f_MQTT_step_startListening>
+  //    - <f_MQTT_step_transportConnect>
+  //
+  //  Related Callback Function Type:
+  //    <fcb_EPTF_MQTT_Transport_apiRequest>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_transportClose(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -431,6 +704,23 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_loadTemplate_byIntIdx
+  //
+  //  Purpose:
+  //    Test step to load a <MQTT_Template> from <tsp_EPTF_MQTT_LGen_templates> into *v_MQTT_msgToSend*
+  //    (which can be sent using the send test step) by its integer index in test step args.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_loadTemplate_byIntIdx>
+  //    - <c_MQTT_stepName_loadTemplate_byIntIdx>
+  //
+  //  Related Function:
+  //    <f_MQTT_step_send>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_loadTemplate_byIntIdx(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -444,6 +734,23 @@
     f_EPTF_MQTT_templateDB_get(vl_templateIdx, v_MQTT_msgToSend.pdu);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_loadTemplate_byStringId
+  //
+  //  Purpose:
+  //    Test step to load a <MQTT_Template> from <tsp_EPTF_MQTT_LGen_templates> into *v_MQTT_msgToSend*
+  //    (which can be sent using the send test step) by its string Id.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_loadTemplate_byStringId>
+  //    - <c_MQTT_stepName_loadTemplate_byStringId>
+  //
+  //  Related Function:
+  //    <f_MQTT_step_send>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_loadTemplate_byStringId(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -464,7 +771,20 @@
     }
   }
 
-  // 1st param: topic name charstring
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setTopic_stringParam
+  //
+  //  Purpose:
+  //    Test step to set the string value referred by the test step argument as the topic of the first subscription entry in SUBSCRIBE and PUBLISH messages.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(1st param: topic name charstring)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setTopic_stringParam>
+  //    - <c_MQTT_stepName_setTopic_stringParam>
+  //
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setTopic_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -490,7 +810,22 @@
 	}
   }
 
-  // 1st param: topic name charstring
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setTopic_add_stringParam
+  //
+  //  Purpose:
+  //    Test step to add the string value referred by the test step argument to the topic of the first subscription entry in SUBSCRIBE and PUBLISH messages.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(1st param: topic name charstring)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setTopic_add_stringParam>
+  //    - <c_MQTT_stepName_setTopic_add_stringParam>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setTopic_add_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -520,7 +855,22 @@
 	}
   }
 
-  // params: variables
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setTopic_add_varParams
+  //
+  //  Purpose:
+  //    Test step to add the string value of variables referred by the test step argument to the topic of the first subscription entry in SUBSCRIBE and PUBLISH messages.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(params: variables)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setTopic_add_varParams>
+  //    - <c_MQTT_stepName_setTopic_add_varParams>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setTopic_add_varParams(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -565,6 +915,22 @@
 	}
   }
 
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setTopic_add_clientId
+  //
+  //  Purpose:
+  //    Test step to add client ID in the current session to the topic in the first subscription in SUBSCRIBE and to PUBLISH message.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(param: clientId)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setTopic_add_clientId>
+  //    - <c_MQTT_stepName_setTopic_add_clientId>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setTopic_add_clientId(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -592,7 +958,22 @@
 	}
   }
 
-  // 1st param: qos level (0,1,2) integer
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setQos_intParam
+  //
+  //  Purpose:
+  //    Test step to set the QoS level in SUBSCRIBE and PUBLISH messages using test step arguments
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(1st param: qos level (0,1,2) integer)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setQos_intParam>
+  //    - <c_MQTT_stepName_setQos_intParam>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setQos_intParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -625,7 +1006,22 @@
 	}
   }
 
-  // 1st param: publish message charstring
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setPublishMessage_stringParam
+  //
+  //  Purpose:
+  //    Test step to set the content of the payload in PUBLISH message.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(1st param: publish message charstring)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setPublishMessage_stringParam>
+  //    - <c_MQTT_stepName_setPublishMessage_stringParam>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setPublishMessage_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -643,7 +1039,22 @@
 	}
   }
 
-  // 1st param: publish message charstring
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setPublishMessage_add_stringParam
+  //
+  //  Purpose:
+  //    Test step to concatenate a string to the content of the PUBLISH message
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(1st param: publish message charstring)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setPublishMessage_add_stringParam>
+  //    - <c_MQTT_stepName_setPublishMessage_add_stringParam>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ////////////////////////////////////////////////////////////
   function f_MQTT_step_setPublishMessage_add_stringParam(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -663,7 +1074,22 @@
 	}
   }
 
-  // params: variables
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setPublishMessage_add_varParams
+  //
+  //  Purpose:
+  //    Test step to add the content of a set of variables to the payload of a PUBLISH message.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(params: variables)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setPublishMessage_add_varParams>
+  //    - <c_MQTT_stepName_setPublishMessage_add_varParams>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setPublishMessage_add_varParams(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -698,6 +1124,22 @@
 	  char2oct(vl_strToAdd);
   }
 
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_setPublishMessage_add_clientId
+  //
+  //  Purpose:
+  //    Test step to add client ID of the current session to the payload of a PUBLISH message.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(param: clientId)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_setPublishMessage_add_clientId>
+  //    - <c_MQTT_stepName_setPublishMessage_add_clientId>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_setPublishMessage_add_clientId(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -715,7 +1157,22 @@
 	}
   }
 
-  // 1st param: enable (1)/disable (0): integer
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_reportPingResponse
+  //
+  //  Purpose:
+  //    Test step to set the report ping response to enable/disable using using step arguments.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args - 1:enable, 0:disable
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_reportPingResponse>
+  //    - <c_MQTT_stepName_reportPingResponse>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_reportPingResponse(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -735,7 +1192,22 @@
 	}
   }
 
-  // 1st param: enable (1)/disable (0): integer
+  /////////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_reportPublishResponse
+  //
+  //  Purpose:
+  //    Test step to set the report publish response to enable/disable using step arguments
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args(1st param: enable (1)/disable (0): integer)
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_reportPublishResponse>
+  //    - <c_MQTT_stepName_reportPublishResponse>
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_reportPublishResponse(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -755,6 +1227,28 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_step_send
+  //
+  //  Purpose:
+  //    Test step to send out an MQTT message from *v_MQTT_msgToSend*.
+  //    The message will be processed by the Applib's MQTT stack
+  //    The step expects the localAddress and the remoteAddress to be configured in addressDB.
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //
+  //  Related Constants:
+  //    - <c_MQTT_stepIdx_send>
+  //    - <c_MQTT_stepName_send>
+  //
+  //  Related Functions:
+  //    - <f_MQTT_step_loadTemplate_byIntIdx>
+  //    - <f_MQTT_step_loadTemplate_byStringId>
+  //
+  //  Related functions:
+  //    <f_EPTF_MQTT_stack_fromApp>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_step_send(in EPTF_LGenBase_TestStepArgs pl_ptr)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -775,6 +1269,17 @@
     f_EPTF_SchedulerComp_refreshSnapshotTime();
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_addressDB_init
+  //
+  //  Purpose:
+  //    Function to initialize the addressDB
+  //
+  //  Parameters:
+  //
+  //  Related Type:
+  //    <MQTT_Address_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_addressDB_init()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -783,6 +1288,17 @@
     v_MQTT_addressDB.hashRef := f_EPTF_str2int_HashMap_New("EPTF_MQTT_addressDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_addressDB_cleanUp
+  //
+  //  Purpose:
+  //    Function to clean up the address database and release its resources
+  //
+  //  Parameters:
+  //
+  //  Related Type:
+  //    <MQTT_Address_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_addressDB_cleanUp()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -791,6 +1307,20 @@
     f_EPTF_str2int_HashMap_Delete("EPTF_MQTT_addressDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_addressDB_add
+  //
+  //  Purpose:
+  //    Add a socket address to the addressDB and return its index if no such entry yet,
+  //    or return its index if already exists
+  //
+  //  Parameters:
+  //    p_addr  - *in* <Socket> - socket address
+  //    p_idx   - *inout* *integer* - index of the address entry
+  //
+  //  Related Type:
+  //    <MQTT_Address_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_addressDB_add(in Socket p_addr, inout integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -806,6 +1336,19 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_addressDB_get
+  //
+  //  Purpose:
+  //    Get a socket address from the addressDB by its index
+  //
+  //  Parameters:
+  //    p_addr  - *inout* <Socket> - returned socket address
+  //    p_idx   - *in* *integer* - index of the address to get
+  //
+  //  Related Type:
+  //    <MQTT_Address_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_addressDB_get(inout Socket p_addr, in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -819,6 +1362,21 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_addressDB_lookUp
+  //
+  //  Purpose:
+  //    Get the index of a socket entry in addressDB
+  //
+  //  Parameters:
+  //    p_sock  - *in* <Socket> - socket address
+  //
+  //  Return Type:
+  //    *integer* - The index of the socket entry
+  //
+  //  Related Type:
+  //    <MQTT_Address_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_addressDB_lookUp(in Socket p_sock)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -828,12 +1386,36 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_addressDB_Socket2String
+  //
+  //  Purpose:
+  //    Converts a socket address in <Socket> type format to the string format "<IP address>:<port number>" to be used as hash key
+  //
+  //  Parameters:
+  //    p_sock  - *inout* <Socket> - socket address
+  //
+  //  Return Type:
+  //    *charstring* - Socket address in string format
+  //
+  //  Related Type:
+  //    <MQTT_Address_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_addressDB_Socket2String(Socket p_sock)
   return charstring
   {
     return p_sock.hostName&":"&int2str(p_sock.portNumber);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_templateDB_init
+  //
+  //  Purpose:
+  //    Initializes the *v_MQTT_templateDB* <MQTT_Template_DB> database by adding the templates given in <tsp_EPTF_MQTT_LGen_templates>
+  //
+  //  Related Type:
+  //    <MQTT_Template_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_templateDB_init()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -845,6 +1427,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_templateDB_add
+  //
+  //  Purpose:
+  //    Adds a new element to the *v_MQTT_templateDB* <MQTT_Template_DB> database
+  //
+  //  Parameters:
+  //    p_template - *in* <MQTT_Template> - the element to be added
+  //
+  //  Returns:
+  //    *integer* - the index of the added element in the database
+  //
+  //  Related Type:
+  //    <MQTT_Template_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_templateDB_add(in MQTT_Template p_template)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -864,6 +1461,21 @@
     return v_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_templateDB_lookUp
+  //
+  //  Purpose:
+  //    Gets the index of an <MQTT_Template> element in *v_MQTT_templateDB* <MQTT_Template_DB> database
+  //
+  //  Parameters:
+  //    p_id - *in* *charstring* - the id of the <MQTT_Template>
+  //
+  //  Returns:
+  //    *integer* - the index of the searched template in the database, or -1 if not found
+  //
+  //  Related Type:
+  //    <MQTT_Template_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_templateDB_lookUp(in charstring p_id)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -876,6 +1488,19 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_templateDB_get
+  //
+  //  Purpose:
+  //    Retrieves an element from the *v_MQTT_templateDB* <MQTT_Template_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be retrieved
+  //    p_pdu - *inout* <MQTT_v3_1_1_ReqResp> - the retrieved element
+  //
+  //  Related Type:
+  //    <MQTT_Template_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_templateDB_get(in integer p_idx, inout MQTT_v3_1_1_ReqResp p_pdu)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -886,6 +1511,15 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_templateDB_cleanUp
+  //
+  //  Purpose:
+  //    Cleans up the reserved resources of the *v_MQTT_templateDB* <MQTT_Template_DB> database
+  //
+  //  Related Type:
+  //    <MQTT_Template_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_templateDB_cleanUp()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -893,6 +1527,15 @@
     f_EPTF_str2int_HashMap_Delete("EPTF_MQTT_templateDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_init
+  //
+  //  Purpose:
+  //    Initializes the *v_MQTT_sessionDB* <MQTT_Session_DB> database and adds its hash to *v_MQTT_sessionDB.hashRef*
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_init()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -901,6 +1544,15 @@
     v_MQTT_sessionDB.hashRef := f_EPTF_str2int_HashMap_New("EPTF_MQTT_sessionDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_cleanUp
+  //
+  //  Purpose:
+  //    Cleans up the reserved resources of the *v_MQTT_sessionDB* <MQTT_Session_DB> database
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_cleanUp()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -909,6 +1561,21 @@
     f_EPTF_str2int_HashMap_Delete("EPTF_MQTT_sessionDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_add
+  //
+  //  Purpose:
+  //    Adds a new element to the *v_MQTT_sessionDB* <MQTT_Session_DB> database
+  //
+  //  Parameters:
+  //    p_session - *in* <MQTT_Session> - the element to be added
+  //
+  //  Returns:
+  //    *integer* - the index of the added element in the database
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_add(in MQTT_Session p_session)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -922,6 +1589,18 @@
     return v_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_setKey
+  //
+  //  Purpose:
+  //    Sets the hash of the local socket address of a session by the session index
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the session index
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_setKey(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -934,6 +1613,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_lookUp
+  //
+  //  Purpose:
+  //    Gets the index of a session in *v_MQTT_sessionDB* <MQTT_Session_DB> database by its socket address
+  //
+  //  Parameters:
+  //    p_sock - *in* <Socket> - the socket address to look up
+  //
+  //  Returns:
+  //    *integer* - the index of the added element in the database, or -1 if not found
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_lookUp(in Socket p_sock)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -944,6 +1638,22 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_get
+  //
+  //  Purpose:
+  //    Retrieves a session's data from the *v_MQTT_sessionDB* <MQTT_Session_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be retrieved
+  //    p_session - *inout* <MQTT_Session> - the retrieved session context
+  //
+  //  Returns:
+  //    *boolean* - true if OK, false if no session element with this index
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_get(in integer p_idx, inout MQTT_Session p_session)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -960,6 +1670,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_check
+  //
+  //  Purpose:
+  //    Checks if a session element exists in the *v_MQTT_sessionDB* <MQTT_Session_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be checked
+  //
+  //  Returns:
+  //    boolean - true if the session exists
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_check(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -974,6 +1699,18 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_remove
+  //
+  //  Purpose:
+  //    Removes an element from the *v_MQTT_sessionDB* <MQTT_Session_DB> database and releases its resources
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be removed
+  //
+  //  Related Type:
+  //    <MQTT_Session_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_remove(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -986,12 +1723,34 @@
     f_EPTF_FBQ_moveFromBusyToFreeTail(p_idx, v_MQTT_sessionDB.queue);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_sessionDB_addrHash
+  //
+  //  Purpose:
+  //    Converts a socket address in <Socket> type format to the string format "<IP address>:<port number>" to be used as a hash key
+  //
+  //  Parameters:
+  //    p_sock - *in* <Socket> - socket address
+  //
+  //  Returns:
+  //    charstring - socket address in string format
+  //
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_sessionDB_addrHash(in Socket p_sock)
   return charstring
   {
     return p_sock.hostName&":"&int2str(p_sock.portNumber);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_init
+  //
+  //  Purpose:
+  //    Initializes the *v_MQTT_publishDB* <MQTT_Publish_DB> database and creates its hashmap 
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_init()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1000,6 +1759,15 @@
     v_MQTT_publishDB.hashRef := f_EPTF_str2int_HashMap_New("EPTF_MQTT_publishDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_cleanUp
+  //
+  //  Purpose:
+  //    Cleans up the reserved resources of the *v_MQTT_publishDB* <MQTT_Publish_DB> database
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_cleanUp()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1008,6 +1776,21 @@
     f_EPTF_str2int_HashMap_Delete("EPTF_MQTT_publishDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_add
+  //
+  //  Purpose:
+  //    Adds a new element to the *v_MQTT_publishDB* <MQTT_Publish_DB> database
+  //
+  //  Parameters:
+  //    p_pub - *in* <MQTT_Publish> - the element to be added
+  //
+  //  Returns:
+  //    *integer* - the index of the added element in the database
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_add(in MQTT_Publish p_pub)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -1027,6 +1810,22 @@
     return v_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_lookUp
+  //
+  //  Purpose:
+  //    Gets the index of an <MQTT_Publish> element in *v_MQTT_publishDB* <MQTT_Publish_DB> database by its session and packet id-s
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - input session id
+  //    p_packetId - *in* *integer* - input packet id
+  //
+  //  Returns:
+  //    *integer* - the index of the searched element in the database, or -1 if not found
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_lookUp(in integer p_sessionIdx, in integer p_packetId)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -1041,6 +1840,22 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_get
+  //
+  //  Purpose:
+  //    Retrieves an element from the *v_MQTT_publishDB* <MQTT_Publish_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be retrieved
+  //    p_pub - *inout* <MQTT_Publish> - the retrieved element
+  //
+  //  Returns:
+  //     boolean - true: success, false: no element with the index p_idx
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_get(in integer p_idx, inout MQTT_Publish p_pub)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -1056,6 +1871,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_check
+  //
+  //  Purpose:
+  //    Checks if an element exists in the *v_MQTT_publishDB* <MQTT_Publish_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be checked
+  //
+  //  Returns:
+  //     boolean - true: element present, false: element doesn't exists
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_check(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -1070,6 +1900,18 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_remove
+  //
+  //  Purpose:
+  //    Removes an element from the *v_MQTT_publishDB* <MQTT_Publish_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be Removed
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_remove(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1089,12 +1931,38 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishDB_packetIdHash
+  //
+  //  Purpose:
+  //    Converts a pair of session ID & packet ID to the string format "session_<sessionId>:id_<packetId>" to be used as a hash key
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - input session ID
+  //    p_packetId - *in* *integer* - input packet ID
+  //
+  //  Returns:
+  //    charstring - converted IDs
+  //
+  //  Related Type:
+  //    <MQTT_Publish_DB>
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishDB_packetIdHash(in integer p_sessionIdx, in integer p_packetId)
   return charstring
   {
     return "session_"&int2str(p_sessionIdx)&":"&"id_"&int2str(p_packetId);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_init
+  //
+  //  Purpose:
+  //    Initializes the *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_init()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1103,6 +1971,15 @@
     v_MQTT_subscriptionDB.hashRef := f_EPTF_str2int_HashMap_New("EPTF_MQTT_subscriptionDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_cleanUp
+  //
+  //  Purpose:
+  //    Cleans up the reserved resources of the *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_cleanUp()
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1111,6 +1988,21 @@
     f_EPTF_str2int_HashMap_Delete("EPTF_MQTT_subscriptionDB_Hash");
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_add
+  //
+  //  Purpose:
+  //    Adds a new element to the *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //
+  //  Parameters:
+  //    p_sub - *in* <MQTT_Subscription> - the element to be added
+  //
+  //  Returns:
+  //    *integer* - the index of the added element in the database
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_add(in MQTT_Subscription p_sub)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -1145,6 +2037,20 @@
     return v_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_setKey_packetId
+  //
+  //  Purpose:
+  //    Insert an integer element to the subscription hashmap, key is composed from session ID and packet ID
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - data to be inserted
+  //    p_sessionIdx - *in* *integer* - input session ID, used in hashmap key
+  //    p_packetId - *in* *integer* - input packet ID, used in hashmap key
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_setKey_packetId(in integer p_idx, in integer p_sessionIdx, in integer p_packetId)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1155,6 +2061,19 @@
     );
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_removeKey_packetId
+  //
+  //    Removes the element from the subscription hashmap identified by its session ID and packet ID
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - NOT USED
+  //    p_sessionIdx - *in* *integer* - input session ID, used in hashmap key
+  //    p_packetId - *in* *integer* - input packet ID, used in hashmap key
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_removeKey_packetId(in integer p_idx, in integer p_sessionIdx, in integer p_packetId)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1164,6 +2083,23 @@
     );
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_lookUp_packetId
+  //
+  //  Purpose:
+  //    Gets the index of an <MQTT_Subscription> element in *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //    by a session ID and packet ID
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - input session ID, used in hashmap key
+  //    p_packetId - *in* *integer* - input packet ID, used in hashmap key
+  //
+  //  Returns:
+  //    *integer* - the index of the searched element in the database, or -1 if not found
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_lookUp_packetId(in integer p_sessionIdx, in integer p_packetId)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -1178,6 +2114,23 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_lookUp_topicName
+  //
+  //  Purpose:
+  //    Gets the index of an <MQTT_Subscription> element in *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //    by a session ID and packet ID
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - input session ID, used in hashmap key
+  //    p_topicName - *in* *charstring* - input topic, used in hashmap key
+  //
+  //  Returns:
+  //    *integer* - the index of the searched element in the database, or -1 if not found
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_lookUp_topicName(in integer p_sessionIdx, in charstring p_topicName)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -1192,6 +2145,22 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_get
+  //
+  //  Purpose:
+  //    Retrieves an element from the *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be retrieved
+  //    p_sub - *inout* <MQTT_Subscription> - the retrieved element
+  //
+  //  Returns:
+  //    *boolean* - true: success, false: element with this index doesn't exist
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_get(in integer p_idx, inout MQTT_Subscription p_sub)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -1207,6 +2176,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_check
+  //
+  //  Purpose:
+  //    Checks if an element at an index exists the *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be checked
+  //
+  //  Returns:
+  //    *boolean* - true: success, false: element at this index is not present
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_check(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -1221,6 +2205,18 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_remove
+  //
+  //  Purpose:
+  //    Removes an element from the *v_MQTT_subscriptionDB* <MQTT_Subscription_DB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be removed
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_remove(in integer p_idx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1250,18 +2246,64 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_packetIdHash
+  //
+  //  Purpose:
+  //    Converts a pair of session ID & packet ID to the string format "session_<sessionId>:id_<packetId>" to be used as hash key
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - input session ID
+  //    p_packetId - *in* *integer* - input packet ID
+  //
+  //  Returns:
+  //    charstring - converted IDs
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_packetIdHash(in integer p_sessionIdx, in integer p_packetId)
   return charstring
   {
     return "session_"&int2str(p_sessionIdx)&":"&"id_"&int2str(p_packetId);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscriptionDB_topicHash
+  //
+  //  Purpose:
+  //    Converts a pair of session ID & topic to the string format "session_<sessionId>:topic_<topic>" to be used as hash key
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - input session ID
+  //    p_topic - *in* *charstring* - input topic string
+  //
+  //  Returns:
+  //    charstring - converted IDs
+  //
+  //  Related Type:
+  //    <MQTT_Subscription_DB>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscriptionDB_topicHash(in integer p_sessionIdx, in charstring p_topic)
   return charstring
   {
     return "session_"&int2str(p_sessionIdx)&":"&"topic_"&p_topic;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_stack_fromApp
+  //
+  //  Purpose:
+  //    This is the main entry point for the MQTT stack realization of the <EPTF_MQTT_LGen_CT>
+  //    component that handles messages received from the application layer (e.g. FSMs)
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - message that enters into the stack (will be modified by the stack)
+  //    p_ctx - *in* <MQTT_StepCtx> - pointers for the instances related to a particular simulated entity
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_stack_fromApp(inout EPTF_MQTT_PDU p_msg, in MQTT_StepCtx p_ctx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1271,10 +2313,23 @@
     }
     else
     {
-	  f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " sessionIdx is not valid [",p_ctx.sessionIdx,"]. Dropping message"));
+      f_EPTF_MQTT_Logging_WARNING(log2str(%definitionId, " sessionIdx is not valid [",p_ctx.sessionIdx,"]. Dropping message"));
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_stack_fromEnv
+  //
+  //  Purpose:
+  //    This is the main entry point for the MQTT stack realization of the <EPTF_MQTT_LGen_CT>
+  //    component that handles messages received from the environment layer (e.g. transport layer)
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - message that enters into the stack (will be modified by the stack)
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_stack_fromEnv(inout EPTF_MQTT_PDU p_msg)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1310,6 +2365,40 @@
     }
   }
 
+  /*****************************************************************
+    @startuml EPTF_MQTT_LGen_Functions.MQTT_Session.jpg     
+      [*] --> DISCONNECTED
+      DISCONNECTED --> CONNECTING: appIn: connect_msg
+      CONNECTING --> CONNECTED: envIn: connack_accepted
+      CONNECTING --> DISCONNECTED: envIn: connack_refused
+      CONNECTED --> DISCONNECTED: appIn: disconnect
+      CONNECTED --> CONNECTED: appIn: publish
+      CONNECTED --> CONNECTED: envIn: publish
+      CONNECTED --> CONNECTED: appIn: subscribe
+      CONNECTED --> CONNECTED: appIn: unsubscribe
+      CONNECTED --> CONNECTED: envIn: suback
+      CONNECTED --> CONNECTED: envIn: unsuback
+      CONNECTED --> CONNECTED: envIn: pingresp
+      CONNECTED --> CONNECTED: T_keepalive
+    @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_fromApp
+  //
+  //  Purpose:
+  //    This is the entry point for an MQTT session fsm handling events coming from the application layer (e.g. client/broker FSMs)
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - next transport message to be sent
+  //    p_sIdx - *in* *integer* - session index
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  //
+  // FSM Diagram of a MQTT session:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Session.jpg)
+  //
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_fromApp(inout EPTF_MQTT_PDU p_msg, in integer p_sIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1462,6 +2551,22 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_fromEnv
+  //
+  //  Purpose:
+  //    This is the entry point for an MQTT session fsm from the environment layer (e.g. transport layer)
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - transport message received
+  //    p_sIdx - *in* *integer* - session index
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  //
+  // FSM Diagram of a MQTT session:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Session.jpg)
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_sIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1606,6 +2711,22 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_keepalive
+  //
+  //  Purpose:
+  //    Handles the T_keepalive timer event in the <MQTT_Session> FSM
+  //
+  //  Parameters:
+  //    pl_action - *inout* <EPTF_ScheduledAction> - the scheduled action <>
+  //    pl_eventIndex - *in* *integer* - eveny index in the scheduler
+  //
+  //  Returns:
+  //    *boolean* - true <always>
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_keepalive(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -1628,6 +2749,22 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_startT_keepalive
+  //
+  //  Purpose:
+  //    Starts the T_keepalive timer for an <MQTT_Session> FSM
+  //
+  //  Parameters:
+  //    pl_sIdx - *in* *integer* - session index (?)
+  //    pl_time - *in* *float* - value of the keepalive timer
+  //
+  //  Returns:
+  //    *boolean* - true: succesful , false: 0 or negative timer value
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_startT_keepalive(in integer pl_sIdx, in float pl_time)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -1649,6 +2786,18 @@
     return retval;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_cancelT_keepalive
+  //
+  //  Purpose:
+  //    Cancels the T_keepalive timer of an <MQTT_Session> FSM
+  //
+  //  Parameters:
+  //    pl_sessionIdx - *in* *integer* - session index
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_cancelT_keepalive(in integer pl_sessionIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1662,6 +2811,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_getNextPacketId
+  //
+  //  Purpose:
+  //    Sets the value of the packet id field in the next message to be sent in a session
+  //
+  //  Parameters:
+  //    p_ctx - *in* <MQTT_StepCtx> - Pointer of the context embedding the session id. 
+  //
+  //  Returns:
+  //    *integer* - packet id for the next message
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_getNextPacketId(in MQTT_StepCtx p_ctx)
   runs on EPTF_MQTT_LGen_CT
   return integer
@@ -1677,6 +2841,19 @@
     return v_MQTT_sessionDB.data[p_ctx.sessionIdx].nextPacketId;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_setState
+  //
+  //  Purpose:
+  //    Sets a new state for an <MQTT_Session> FSM
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - index of session
+  //    p_nextState - *in* <MQTT_Session_State> - new state of the state machine
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_setState(in integer p_sessionIdx, in MQTT_Session_State p_nextState)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1684,6 +2861,19 @@
 	f_EPTF_MQTT_Logging_VERBOSE(log2str("session [", p_sessionIdx,":",v_MQTT_sessionDB.data[p_sessionIdx].clientId,"] next state: ", v_MQTT_sessionDB.data[p_sessionIdx].state));
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_send
+  //
+  //  Purpose:
+  //    Sends a message to the transort layer with type <EPTF_MQTT_PDU> and the provided session index
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - session index
+  //    p_msg - *intout* <EPTF_MQTT_PDU> - the message to be sent
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_send(in integer p_sessionIdx, inout EPTF_MQTT_PDU p_msg)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1697,6 +2887,19 @@
     f_EPTF_MQTT_LGen_send(p_msg);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_registerSubscription
+  //
+  //  Purpose:
+  //    Adds a subscription index to an <MQTT_Session>
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - session index
+  //    p_subIdx - *in* *integer* - subscription index to add
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_registerSubscription(in integer p_sessionIdx, in integer p_subIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1705,6 +2908,19 @@
       := p_subIdx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_deregisterSubscription
+  //
+  //  Purpose:
+  //    Removes a subscription index from <MQTT_Session>
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - session index
+  //    p_subIdx - *in* *integer* - subscription index to remove
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_deregisterSubscription(in integer p_sessionIdx, in integer p_subIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1720,6 +2936,19 @@
     v_MQTT_sessionDB.data[p_sessionIdx].subscriptionRefs := vl_new;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_registerPublish
+  //
+  //  Purpose:
+  //    Adds a publish index to an <MQTT_Session>
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - session index
+  //    p_subIdx - *in* *integer* - publish index to add
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_registerPublish(in integer p_sessionIdx, in integer p_pubIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1728,6 +2957,19 @@
       := p_pubIdx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_deregisterPublish
+  //
+  //  Purpose:
+  //    Removes a publish index from an <MQTT_Session>
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - session index
+  //    p_subIdx - *in* *integer* - publish index to add
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_deregisterPublish(in integer p_sessionIdx, in integer p_pubIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1743,6 +2985,18 @@
     v_MQTT_sessionDB.data[p_sessionIdx].publishRefs := vl_new;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_session_remove
+  //
+  //  Purpose:
+  //    Releases all resources related to an <MQTT_Session> and removes it from the <MQTT_Session_DB>
+  //
+  //  Parameters:
+  //    p_sessionIdx - *in* *integer* - session index
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_session_remove(in integer p_sessionIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1767,6 +3021,32 @@
     f_EPTF_MQTT_sessionDB_remove(p_sessionIdx);
   }
 
+  /*****************************************************************
+    @startuml EPTF_MQTT_LGen_Functions.MQTT_Subscription.jpg     
+      [*] --> UNSUBSCRIBED
+      UNSUBSCRIBED --> SUBSCRIBING: sessionIn: subscribe
+      SUBSCRIBED --> UNSUBSCRIBING: sessionIn: unsubscribe
+      SUBSCRIBING --> SUBSCRIBED: envIn: suback_accepted
+      SUBSCRIBING --> UNSUBSCRIBED: envIn: suback_refused
+      UNSUBSCRIBING --> UNSUBSCRIBED: envIn: unsuback
+    @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscription_fromSession
+  //
+  //  Purpose:
+  //    Implements part of the <MQTT_Subscription> FSM that handles the events coming from the <MQTT_Session>
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - message that
+  //    p_subIdx - *in* *integer* - subscription index
+  //
+  //  Related Types:
+  //    <MQTT_Subscription>
+  //
+  // FSM Diagram of a MQTT subscription:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Subscription.jpg)
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscription_fromSession(inout EPTF_MQTT_PDU p_msg, in integer p_subIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1815,6 +3095,22 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscription_fromEnv
+  //
+  //  Purpose:
+  //    Implements part of the <MQTT_Subscription> FSM that handles the events coming from the environment
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - received transport message
+  //    p_subIdx - *in* *integer* - subscription index
+  //
+  //  Related Types:
+  //    <MQTT_Subscription>
+  //
+  // FSM Diagram of a MQTT subscription:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Subscription.jpg)
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscription_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_subIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1885,6 +3181,19 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscription_setState
+  //
+  //  Purpose:
+  //    Sets a new state of a <MQTT_Subscription> FSM
+  //
+  //  Parameters:
+  //    p_subIdx - *in* *integer* - subscription index
+  //    p_nextState - *in* <MQTT_Subscription_State> - new state in the state machine
+  //
+  //  Related Types:
+  //    <MQTT_Subscription>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscription_setState(in integer p_subIdx, in MQTT_Subscription_State p_nextState)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1892,6 +3201,18 @@
 	f_EPTF_MQTT_Logging_VERBOSE(log2str("subscription next state: ", v_MQTT_subscriptionDB.data[p_subIdx].state));
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_subscription_remove
+  //
+  //  Purpose:
+  //    Removing resources related to <MQTT_Subscription> FSM
+  //
+  //  Parameters:
+  //    p_subIdx - *in* *integer* - subscription index
+  //
+  //  Related Types:
+  //    <MQTT_Subscription>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_subscription_remove(in integer p_subIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1904,6 +3225,39 @@
     f_EPTF_MQTT_subscriptionDB_remove(p_subIdx);
   }
 
+  /*****************************************************************
+    @startuml EPTF_MQTT_LGen_Functions.MQTT_Publish_qos1.jpg
+      [*] --> CREATED
+      CREATED --> PUBLISHED: sessionIn: publish
+	  PUBLISHED --> ACKNOWLEDGED: envIn: puback
+    @enduml
+
+    @startuml EPTF_MQTT_LGen_Functions.MQTT_Publish_qos2.jpg
+      [*] --> CREATED
+      CREATED --> PUBLISHED: sessionIn: publish
+	  PUBLISHED --> RELEASED: envIn: pubrec (orig)
+	  PUBLISHED --> RECEIVED: envIn: pubrec (term)
+	  RELEASED --> COMPLETE: envIn: pubcomp (orig)
+	  RECEIVED --> COMPLETE: envIn: pubcomp (term)
+    @enduml
+  ******************************************************************/
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_fromSession
+  //
+  //  Purpose:
+  //    Handles a publish transaction in case of QoS 1 and QoS 2 fsm requested by the application layer (e.g. client/broker FSMs)
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - transport message 
+  //    p_pubIdx - *in* *integer* - publish index
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  //
+  // FSM Diagram of a MQTT publish:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Publish_qos1.jpg)
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Publish_qos2.jpg)
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_fromSession(inout EPTF_MQTT_PDU p_msg, in integer p_pubIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -1966,6 +3320,23 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_fromEnv
+  //
+  //  Purpose:
+  //    Handles PUBLISH and publish response (PUB REC/PUB REL/PUB COMP) messages received from the peer (i.e. from transport layer) based on its QoS and originator
+  //
+  //  Parameters:
+  //    p_msg - *inout* <EPTF_MQTT_PDU> - received transport message
+  //    p_pubIdx - *in* *integer* - publish index
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  //
+  // FSM Diagram of a MQTT publish:
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Publish_qos1.jpg)
+  //   (see EPTF_MQTT_LGen_Functions.MQTT_Publish_qos2.jpg)
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_fromEnv(inout EPTF_MQTT_PDU p_msg, in integer p_pubIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2136,6 +3507,22 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_watchdog
+  //
+  //  Purpose:
+  //    Handles the T_watchdog event in the <MQTT_Publish> FSM
+  //
+  //  Parameters:
+  //    pl_action - *in* <EPTF_ScheduledAction> - scheduled action 
+  //    pl_eventIndex - *in* *integer* - event index
+  //
+  //  Returns:
+  //    *boolean* - true <always>
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_watchdog(in EPTF_ScheduledAction pl_action, in integer pl_eventIndex)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -2155,6 +3542,22 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_startT_watchdog
+  //
+  //  Purpose:
+  //    Start a T_watchdog timer in the <MQTT_Publish> FSM
+  //
+  //  Parameters:
+  //    pl_pIdx - *in* *integer* - publish transaction index
+  //    pl_time - *in* *float* - time from now when the action takes place
+  //
+  //  Returns:
+  //    *boolean* - true: action scheduled , false: 0 or negative timer value is passed
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_startT_watchdog(in integer pl_pIdx, in float pl_time)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -2170,12 +3573,25 @@
       f_EPTF_SchedulerComp_snapshotTime() + pl_time,
       refers(f_EPTF_MQTT_publish_watchdog),
       vl_actionId,
-      v_MQTT_publishDB.data[pl_pIdx].watchdogTimer
+      v_MQTT_publishDB.data[pl_pIdx].watchdogTimer //sets the event index of the next publish watchdog action
     );
 
     return retval;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_setState
+  //
+  //  Purpose:
+  //    Sets the new state of a <MQTT_Publish> FSM
+  //
+  //  Parameters:
+  //    p_pubIdx - *in* *integer* - index of the publish FSM in publishDB
+  //    p_nextState - *in* <MQTT_Publish_State> - new state of the state machine
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_setState(in integer p_pubIdx, in MQTT_Publish_State p_nextState)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2183,6 +3599,18 @@
 	f_EPTF_MQTT_Logging_VERBOSE(log2str("publish next state: ", v_MQTT_publishDB.data[p_pubIdx].state));
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_cancelT_watchdog
+  //
+  //  Purpose:
+  //    Cancels the T_watchdog timer of an <MQTT_Publish> FSM
+  //
+  //  Parameters:
+  //    pl_publishIdx - *in* *integer* - index of the publish FSM in publishDB
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_cancelT_watchdog(in integer pl_publishIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2196,6 +3624,18 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publish_remove
+  //
+  //  Purpose:
+  //    Releaseing resources of an <MQTT_Publish> FSM
+  //
+  //  Parameters:
+  //    p_pubIdx - *in* *integer* - publish index
+  //
+  //  Related Types:
+  //    <MQTT_Publish>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publish_remove(in integer p_pubIdx)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2211,6 +3651,23 @@
     f_EPTF_MQTT_publishDB_remove(p_pubIdx);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_setStepCtx
+  //
+  //  Purpose:
+  //    Sets the entity and FSM indexes in the MQTT step context
+  //
+  //  Parameters:
+  //    pl_ptr - *in* <EPTF_LGenBase_TestStepArgs> - test step args
+  //    p_ctx - *inout* <MQTT_StepCtx> - returns MQTT step context
+  //
+  //  Return Type:
+  //    *boolean* - was the operation successful?
+  //
+  //  Related Function:
+  //    <f_MQTT_step_init>
+  //    
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_setStepCtx(in EPTF_LGenBase_TestStepArgs pl_ptr, inout MQTT_StepCtx p_ctx)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -2228,6 +3685,23 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_setCtx
+  //
+  //  Purpose:
+  //    Sets the instance pointers of <MQTT_StepCtx> to the related instances of a simulated device (entity) and FSM
+  //
+  //  Parameters:
+  //    p_eIdx - *in* *integer* - entity index
+  //    p_fsmIdx - *in* *integer* - FSM index
+  //    p_ctx - *inout* MQTT_StepCtx - returned context value
+  //
+  //  Related Functions:
+  //    <f_MQTT_step_init>
+  //
+  //  Related Types:
+  //    <MQTT_StepCtx>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_setCtx(in integer p_eIdx, in integer p_fsmIdx, inout MQTT_StepCtx p_ctx)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -2245,6 +3719,23 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_isFsmInitialized
+  //
+  //  Purpose:
+  //    Checks if an FSM instance has already been initialized
+  //
+  //  Parameters:
+  //    p_eIdx - *in* *integer* - entity index
+  //    p_fsmIdx - *in* *integer* - FSM index
+  //    pl_sessionIdx - *inout* *integer* - returns session index if initialized,  -1 if not
+  //  
+  //  Returns:
+  //    boolean - true: initialized, false: not initialized
+  //
+  //  Related Types:
+  //    <MQTT_Session>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_isFsmInitialized(in integer pl_eIdx, in integer pl_fsmIdx, inout integer pl_sessionIdx)
   runs on EPTF_MQTT_LGen_CT
   return boolean
@@ -2261,6 +3752,20 @@
     return -1 < pl_sessionIdx and sizeof(v_MQTT_sessionDB.data) > pl_sessionIdx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_getIntValue
+  //
+  //  Purpose:
+  //    Retreives an element of an <EPTF_IntegerList> if it exists
+  //
+  //  Parameters:
+  //    pl_intList - *in* <EPTF_IntegerList> - list of integers
+  //    pl_number - *in* *integer* - index of the integer to be retrieved
+  //    pl_value - *inout* *integer* - returns the value of the retrieved integer
+  //  
+  //  Returns:
+  //    *boolean* - true if the element exists in the integer list
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_getIntValue(
     in EPTF_IntegerList pl_intList,
     in integer pl_number,
@@ -2275,6 +3780,18 @@
     return false;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_Logging_VERBOSE
+  //
+  //  Purpose:
+  //    Logging functions for the VERBOSE log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_Logging_VERBOSE(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2283,6 +3800,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_Logging_DEBUG
+  //
+  //  Purpose:
+  //    Logging functions for the DEBUG log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_Logging_DEBUG(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2291,6 +3820,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_Logging_WARNING
+  //
+  //  Purpose:
+  //    Logging functions for the WARNING log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_Logging_WARNING(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2299,6 +3840,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_Logging_ERROR
+  //
+  //  Purpose:
+  //    Logging functions for the ERROR log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_Logging_ERROR(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2307,6 +3860,21 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_dispatchEvent
+  //
+  //  Purpose:
+  //    Dispatches events to an entity/fsm
+  //
+  //  Parameters:
+  //    pl_eventIdx - *in* *integer* - index of the event
+  //    pl_eIdx - *in* *integer* - the index of the entity
+  //    pl_fsmCtx - *in* *integer* - the index of FSM
+  //    pl_reportedArgs - *in* <EPTF_IntegerList> - additional arguments to be reported to the entity/FSM
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_dispatchEvent(in integer pl_eventIdx, in integer pl_eIdx, in integer pl_fsmCtx, in EPTF_IntegerList pl_reportedArgs)
   runs on EPTF_MQTT_LGen_CT
   {
@@ -2358,6 +3926,21 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_qos_int2enum
+  //
+  //  Purpose:
+  //    Converts the integer value of QoS to its enumerated value
+  //
+  //  Parameters:
+  //    p_qos - *in* *integer* - integer QoS value
+  //
+  //  Return Type:
+  //    <QoS> - enumerated value of the input QoS
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_qos_int2enum(in integer p_qos)
   return QoS
   {
@@ -2373,6 +3956,21 @@
     return RESERVED;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishResponseType
+  //
+  //  Purpose:
+  //    Checks if an MQTT message is a response to a PUBLISH
+  //
+  //  Parameters:
+  //    p_msg - *in* <MQTT_v3_1_1_ReqResp> - the MQTT message to be checked
+  //
+  //  Return Type:
+  //    *boolean* - true: message is a publish response type message
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LGen_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishResponseType(in MQTT_v3_1_1_ReqResp p_msg)
   return boolean
   {
@@ -2383,6 +3981,18 @@
       ischosen(p_msg.pubcomp)
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_publishResponsePacketId
+  //
+  //  Purpose:
+  //    Get the packet identifier of an MQTT message, if it is a response to a PUBLISH 
+  //
+  //  Parameters:
+  //    p_msg - *in* <MQTT_v3_1_1_ReqResp> - the input MQTT message
+  //
+  //  Return Type:
+  //    *integer* - Packet identifier value if the message was of a PUBLISH response type, -1 in other cases
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_publishResponsePacketId(in MQTT_v3_1_1_ReqResp p_msg)
   return integer
   {
diff --git a/src/EPTF_MQTT_LocalTransport_Definitions.ttcn b/src/EPTF_MQTT_LocalTransport_Definitions.ttcn
index 2e50003..ef4e308 100644
--- a/src/EPTF_MQTT_LocalTransport_Definitions.ttcn
+++ b/src/EPTF_MQTT_LocalTransport_Definitions.ttcn
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2000-2019 Ericsson Telecom AB
+// Copyright (c) 2000-2020 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
@@ -9,11 +9,32 @@
 ///////////////////////////////////////////////////////////////////////////////
 //  File:               EPTF_MQTT_LGen_Definitions.ttcn
 //  Description:
-//  Rev:                R1A
+//  Rev:                <RnXnn>
 //  Prodnr:             CNL 113 860
-//  Updated:            2017-09-01
+//  Updated:            2020-01-07
 //  Contact:            http://ttcn.ericsson.se
 ///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+//  Module: EPTF_MQTT_LocalTransport_Definitions
+// 
+//  Purpose:
+//    This module contains the definitions for the MQTT local transport component
+//
+//  Module depends on:
+//    - <EPTF_MQTT_Transport_Definitions>
+//    - <EPTF_CLL_Base_Definitions>
+//    - <EPTF_CLL_Logging_Definitions>
+//    - <EPTF_CLL_FBQ_Definitions>
+//    - <EPTF_CLL_TransportCommPortIPL4_Definitions>
+//    - <EPTF_CLL_RBTScheduler_Definitions>
+//    - <IPL4asp_Types>
+// 
+//  Module Parameters:
+//    tsp_EPTF_MQTT_LocalTransport_debug - <tsp_EPTF_MQTT_LocalTransport_debug> - *boolean* - Enabled/disable debug logging
+//    tsp_EPTF_MQTT_LocalTransport_debugVerbose - <tsp_EPTF_MQTT_LocalTransport_debugVerbose> - *boolean* - Enabled/disable verbosity of debug logging
+//
+///////////////////////////////////////////////////////////////
 module EPTF_MQTT_LocalTransport_Definitions
 {
   import from EPTF_MQTT_Transport_Definitions all;
@@ -24,7 +45,32 @@
   import from EPTF_CLL_RBTScheduler_Definitions all;
   import from IPL4asp_Types all;
 
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_LocalTransport_debug
+  // 
+  //  Purpose:
+  //    Enabled/disable debug logging
+  //  
+  //  Type:
+  //     *boolean*
+  //
+  //  Default value:
+  //     *false*
+  ///////////////////////////////////////////////////////////
   modulepar boolean tsp_EPTF_MQTT_LocalTransport_debug := false;
+
+  ///////////////////////////////////////////////////////////
+  //  Module parameter: tsp_EPTF_MQTT_LocalTransport_debugVerbose
+  // 
+  //  Purpose:
+  //    Enabled/disable verbosity of debug logging
+  //  
+  //  Type:
+  //     *boolean*
+  //
+  //  Default value:
+  //     *false*
+  ///////////////////////////////////////////////////////////
   modulepar boolean tsp_EPTF_MQTT_LocalTransport_debugVerbose := false;
 
   const charstring c_MQTT_Transport_LGenType := "MQTT_Transport";
diff --git a/src/EPTF_MQTT_LocalTransport_Functions.ttcn b/src/EPTF_MQTT_LocalTransport_Functions.ttcn
index e20b65e..b1015e6 100644
--- a/src/EPTF_MQTT_LocalTransport_Functions.ttcn
+++ b/src/EPTF_MQTT_LocalTransport_Functions.ttcn
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2000-2019 Ericsson Telecom AB
+// Copyright (c) 2000-2020 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
@@ -9,11 +9,22 @@
 ///////////////////////////////////////////////////////////////////////////////
 //  File:               EPTF_MQTT_LocalTransport_Functions.ttcn
 //  Description:
-//  Rev:                R1A
+//  Rev:                <RnXnn>
 //  Prodnr:             CNL 113 860
-//  Updated:            2017-09-01
+//  Updated:            2020-01-07
 //  Contact:            http://ttcn.ericsson.se
 ///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+//  Module: EPTF_MQTT_LocalTransport_Functions
+// 
+//  Purpose:
+//    This module contains the functions of the MQTT local transport component
+//
+//  See also:
+//    <EPTF_MQTT_LocalTransport_Definitions>
+///////////////////////////////////////////////////////////////
+
 module EPTF_MQTT_LocalTransport_Functions
 {
   import from IPL4asp_Types all;
@@ -34,6 +45,15 @@
   import from MQTT_v3_1_1_Types all;
   import from MQTT_v3_1_1_IPL4SizeFunction all;
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_init
+  //
+  //  Purpose:
+  //    The main initialization function of the <EPTF_MQTT_LocalTransport_CT> component type
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_init()
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -58,6 +78,15 @@
     v_EPTF_MQTT_LocalTransport_initialized := true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_initLogging
+  //
+  //  Purpose:
+  //    Initializing CLL's logging feature on the <EPTF_MQTT_LocalTransport_CT> component type
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_initLogging()
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -84,6 +113,15 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_cleanup
+  //
+  //  Purpose:
+  //    The main clean up function for the <EPTF_MQTT_LocalTransport_CT> component type
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_cleanup()
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -97,6 +135,20 @@
     v_EPTF_MQTT_LocalTransport_initialized := false;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_IPL4asp_handleEvent
+  //
+  //  Purpose:
+  //    Handler function to be registered into the IPL4 transport layer <EPTF_CLL_TransportIPL4_Functions>.
+  //    It is used to receieve transport events from the underlying IPL4 transport layer.
+  //    The function currently handles the connection closed event and forwards every event to the load generator
+  //    layer's handler function.
+  //
+  //  Parameters:
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_IPL4asp_handleEvent() runs on EPTF_MQTT_LocalTransport_CT
   {
     f_MQTT_Transport_Logging_DEBUG(log2str(": incoming event: ", v_EPTF_CommPort_IPL4_incomingMessage));
@@ -125,6 +177,20 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_IPL4asp_handleMessage
+  //
+  //  Purpose:
+  //    Handler function to be regisitered into the IPL4 transport layer <EPTF_CLL_TransportIPL4_Functions>.
+  //    It is used to receieve MQTT messages from the underlying IPL4 transport layer.
+  //    The function looks up the entity that owns the particular connection and forwards the message and the
+  //    entity information to the load generator layer
+  //
+  //  Parameters:
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_IPL4asp_handleMessage() runs on EPTF_MQTT_LocalTransport_CT
   {
     var MQTT_v3_1_1_Message vl_MQTT_MSG;
@@ -171,6 +237,19 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_send
+  //
+  //  Purpose:
+  //    Function to send out a <EPTF_MQTT_PDU> message using the local transport. It automatically
+  //    looks up the corresponding <Socket> or creates it on the fly if it doesn't exist yet
+  //
+  //  Parameters:
+  //    pl_msg - *in* <EPTF_MQTT_PDU> - message to be sent
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_send(in EPTF_MQTT_PDU pl_msg)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -206,6 +285,18 @@
     );
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_transportApiRequest
+  //
+  //  Purpose:
+  //    Function to handle incoming transport API requests
+  //
+  //  Parameters:
+  //    pl_req - *in* <EPTF_MQTT_Transport_Request> - transport API request
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_transportApiRequest(EPTF_MQTT_Transport_Request pl_req)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -271,6 +362,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_sendApiResponse
+  //
+  //  Purpose:
+  //    Function to handle incoming transport API requests
+  //
+  //  Parameters:
+  //    pl_rsp - *in* <EPTF_MQTT_Transport_Response> - transport API response
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_sendApiResponse(EPTF_MQTT_Transport_Response pl_rsp)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -281,6 +384,23 @@
     }
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_startListening
+  //
+  //  Purpose:
+  //    Start listening on a local TCP socket and store its data and state in socketDB
+  //
+  //  Parameters:
+  //    p_local - *in* <Socket> - local socket
+  //    p_sessionIdx - *in* *integer* - session Id stored with the socket data in socketDB
+  //    p_idx - *inout* *integer* - the index of the added element in the database
+  //
+  //  Return Type:
+  //    *boolean* - was the operation succesful?
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_startListening(in Socket p_local, in integer p_sessionIdx, inout integer p_idx)
   runs on EPTF_MQTT_LocalTransport_CT
   return boolean
@@ -322,6 +442,24 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_connect
+  //
+  //  Purpose:
+  //    Open a TCP connection and store its data and state in socketDB
+  //
+  //  Parameters:
+  //    p_local - *in* <Socket> - local socket
+  //    p_remote - *in* <Socket> - remote socket
+  //    pl_sessionIdx - *in* *integer* - session Id stored with the connection data in socketDB 
+  //    p_idx - *inout* *integer* - the index of the added element in the database
+  //
+  //  Return Value:
+  //    *boolean* - was the operation succesful?
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_connect(in Socket p_local, in Socket p_remote, in integer p_sessionIdx, inout integer p_idx)
   runs on EPTF_MQTT_LocalTransport_CT
   return boolean
@@ -365,6 +503,21 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_close
+  //
+  //  Purpose:
+  //    Close a TCP connection and remove its entry from the socketDB
+  //
+  //  Parameters:
+  //    p_socketIdx - *in* *integer* - the index of the connection in socketDB to be closed
+  //
+  //  Return Value:
+  //    *boolean* - was the operation succesful?
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_close(in integer p_socketIdx)
   runs on EPTF_MQTT_LocalTransport_CT
   return boolean
@@ -402,6 +555,22 @@
     return true;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_IPL4_send
+  //
+  //  Purpose:
+  //    Send a message and add 1 message and its length to MQTT transport stats variable
+  //
+  //  Parameters:
+  //    pl_connId - *in* *integer* - connection Id
+  //    pl_remName - *in* *charstring* - name of the remote host
+  //    pl_remPort - *in* *integer* - remote port number
+  //    pl_proto - *in* <ProtoTuple> - type of protocol of the connection
+  //    pl_msg - *in* *octetstring* - message to be sent
+  //
+  //  Related Type:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////    
   function f_EPTF_MQTT_LocalTransport_IPL4_send(
     in integer pl_connId,
     in charstring pl_remName,
@@ -438,6 +607,16 @@
     v_EPTF_MQTT_Transport_stats.nofSentBytes := v_EPTF_MQTT_Transport_stats.nofSentBytes + int2float(lengthof(pl_msg));
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_init
+  //
+  //  Purpose:
+  //    Initializes the *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_socketDB_init()
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -447,6 +626,16 @@
     v_MQTT_LocalTransport_localSocketDB.connIdHashRef := f_EPTF_int2int_HashMap_New(c_EPTF_MQTT_LocalTransport_SocketDB_connId);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_cleanUp
+  //
+  //  Purpose:
+  //    Cleans up the reserved resources of the *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_socketDB_cleanUp()
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -456,6 +645,22 @@
     f_EPTF_int2int_HashMap_Delete(c_EPTF_MQTT_LocalTransport_SocketDB_connId);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_add
+  //
+  //  Purpose:
+  //    Adds a new element to the *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database
+  //
+  //  Parameters:
+  //    p_sock - *in* <SocketEntry> - the element to be added
+  //
+  //  Returns:
+  //    *integer* - the index of the added element in the database
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_socketDB_add(in SocketEntry p_sock)
   runs on EPTF_MQTT_LocalTransport_CT
   return integer
@@ -478,6 +683,23 @@
     return v_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_lookUp
+  //
+  //  Purpose:
+  //    Gets the index of an <SocketEntry> element in *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database
+  //    based on its socket data
+  //
+  //  Parameters:
+  //    p_sock - *in* <Socket> - socket data of the element to be found
+  //
+  //  Returns:
+  //    *integer* - the index of the element, or -1 if not found
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_socketDB_lookUp(in Socket p_sock)
   runs on EPTF_MQTT_LocalTransport_CT
   return integer
@@ -488,6 +710,23 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_lookUp_connId
+  //
+  //  Purpose:
+  //    Gets the index of an <SocketEntry> element in *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database
+  //    based on its connection id
+  //
+  //  Parameters:
+  //    p_connId - *in* *integer* - the connection id
+  //
+  //  Returns:
+  //    *integer* - the index of the element, or -1 if not found
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////  
   function f_EPTF_MQTT_LocalTransport_socketDB_lookUp_connId(in integer p_connId)
   runs on EPTF_MQTT_LocalTransport_CT
   return integer
@@ -498,6 +737,23 @@
     return vl_idx;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_get
+  //
+  //  Purpose:
+  //    Retrieves an element from the *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be retrieved
+  //    p_sock - *inout* <SocketEntry> - the retrieved element
+  //
+  //  Returns:
+  //    boolean - was the operation successful?
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_socketDB_get(in integer p_idx, inout SocketEntry p_sock)
   runs on EPTF_MQTT_LocalTransport_CT
   return boolean
@@ -510,6 +766,19 @@
     return false;
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_LocalTransport_socketDB_remove
+  //
+  //  Purpose:
+  //    Removes an element from the *v_MQTT_LocalTransport_localSocketDB* <SocketDB> database and frees up its reserved resources
+  //
+  //  Parameters:
+  //    p_idx - *in* *integer* - the index of the element to be removed
+  //
+  //  Related Type:
+  //    <SocketDB>
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_LocalTransport_socketDB_remove(in integer p_idx)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -527,12 +796,36 @@
     f_EPTF_FBQ_moveFromBusyToFreeTail(p_idx, v_MQTT_LocalTransport_localSocketDB.queue);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_Socket2String
+  //
+  //  Purpose:
+  //    Converts socket data from <Socket> type to the format "<hostname>:<port number>"
+  //
+  //  Parameters:
+  //    p_sock - *in* <Socket> - Socket data to be converted
+  //
+  //  Return:
+  //    charstring - the converted socket data
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_Socket2String(Socket p_sock)
   return charstring
   {
     return p_sock.hostName&":"&int2str(p_sock.portNumber);
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_Transport_Logging_VERBOSE
+  //
+  //  Purpose:
+  //    Logging functions for the VERBOSE log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_Transport_Logging_VERBOSE(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -541,6 +834,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_Transport_Logging_DEBUG
+  //
+  //  Purpose:
+  //    Logging functions for the DEBUG log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_Transport_Logging_DEBUG(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -549,6 +854,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_Transport_Logging_WARNING
+  //
+  //  Purpose:
+  //    Logging functions for the WARNING log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_Transport_Logging_WARNING(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -557,6 +874,18 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_MQTT_Transport_Logging_ERROR
+  //
+  //  Purpose:
+  //    Logging functions for the ERROR log level
+  //
+  //  Parameters:
+  //    pl_message - *in* *charstring* - string to be logged
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_MQTT_Transport_Logging_ERROR(in @lazy charstring pl_message)
   runs on EPTF_MQTT_LocalTransport_CT
   {
@@ -565,6 +894,21 @@
 	}
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Function: f_EPTF_MQTT_IPL4asp_handleResult
+  //
+  //  Purpose:
+  //    Checks the result of an IPL4 transport operation and records an MQTT transport stats warning if unsuccessful
+  //
+  //  Parameters:
+  //    p_res - *inout* *Result* - result of an IPL4 transport operation
+  //
+  //  Return Type:
+  //    boolen - *true*: no error or "Temporary unavailable", *false*: error different from "Temporary unavailable"
+  //
+  //  Related Types:
+  //    <EPTF_MQTT_LocalTransport_CT>
+  ///////////////////////////////////////////////////////////
   function f_EPTF_MQTT_IPL4asp_handleResult(inout Result p_res)
   runs on EPTF_MQTT_LocalTransport_CT
   return boolean
diff --git a/src/EPTF_MQTT_Transport_Definitions.ttcn b/src/EPTF_MQTT_Transport_Definitions.ttcn
index 4cd335b..bb2e0db 100644
--- a/src/EPTF_MQTT_Transport_Definitions.ttcn
+++ b/src/EPTF_MQTT_Transport_Definitions.ttcn
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2000-2019 Ericsson Telecom AB
+// Copyright (c) 2000-2020 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
@@ -11,20 +11,127 @@
 //  Description:
 //  Rev:                R1A
 //  Prodnr:             CNL 113 860
-//  Updated:            2017-09-01
+//  Updated:            2020-01-07
 //  Contact:            http://ttcn.ericsson.se
 ///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+//  Module: EPTF_MQTT_Transport_Definitions
+// 
+//  Purpose:
+//    This module contains the definitions of callback functions for the Applib user API
+//
+//  Module depends on:
+//    - <MQTT_v3_1_1_Types>
+//    - <IPL4asp_Types>
+//
+//  Component Diagram:
+//    (see EPTF_MQTT_Transport_Definitions.components.jpg)
+//
+//  See also:
+//    - <EPTF_MQTT_LGen_Definitions>
+//    - <EPTF_MQTT_Transport_User_CT>
+//    - <EPTF_MQTT_Transport_Provider_CT>
+// 
+//  Type:
+//    EPTF_MQTT_PDU - <EPTF_MQTT_PDU> - Encapsulates a MQTT PDU with the corresponding entity (and FSM) indices and transport information
+//
+//  Callback Function types:
+//    fcb_EPTF_MQTT_Transport_receiveMessage - <fcb_EPTF_MQTT_Transport_receiveMessage> - Call-back function type for reporting received <EPTF_MQTT_PDU> MQTT message
+//    fcb_EPTF_MQTT_Transport_receiveEvent - <fcb_EPTF_MQTT_Transport_receiveEvent> - Call-back function type for reporting received <ASP_Event> MQTT event
+//    fcb_EPTF_MQTT_Transport_sendMessage - <fcb_EPTF_MQTT_Transport_sendMessage> - Call-back function type for sending a <EPTF_MQTT_PDU> MQTT message
+//    fcb_EPTF_MQTT_Transport_apiRequest - <fcb_EPTF_MQTT_Transport_apiRequest> - Call-back function type for sending a <EPTF_MQTT_Transport_Request> MQTT transport request
+//    fcb_EPTF_MQTT_Transport_apiResponse - <fcb_EPTF_MQTT_Transport_apiResponse> - Call-back function type for reporting a <EPTF_MQTT_Transport_Response> MQTT transport response
+//
+///////////////////////////////////////////////////////////////
+/*****************************************************************
+ @startuml EPTF_MQTT_Transport_Definitions.components.jpg
+   package "EPTF_MQTT_Transport_Definitions" {
+     class EPTF_MQTT_Transport_User_CT {
+       fcb_EPTF_MQTT_Transport_sendMessage vf_EPTF_MQTT_Transport_send
+       fcb_EPTF_MQTT_Transport_apiRequest vf_EPTF_MQTT_Transport_apiRequest
+     }
+     class EPTF_MQTT_Transport_Provider_CT {
+       fcb_EPTF_MQTT_Transport_receiveMessage vf_EPTF_MQTT_Transport_receiveMessage
+       fcb_EPTF_MQTT_Transport_receiveEvent fcb_EPTF_MQTT_Transport_receiveEvent
+       fcb_EPTF_MQTT_Transport_apiResponse vf_EPTF_MQTT_Transport_apiResponse
+     }
+     EPTF_MQTT_Transport_Provider_CT <-> EPTF_MQTT_Transport_User_CT
+  }
+ @enduml
+******************************************************************/
+
 module EPTF_MQTT_Transport_Definitions
 {
   import from MQTT_v3_1_1_Types all;
   import from IPL4asp_Types all;
 
+  ///////////////////////////////////////////////////////////
+  //  Type: fcb_EPTF_MQTT_Transport_receiveMessage
+  //
+  //  Purpose:
+  //    Call-back function type for reporting received <EPTF_MQTT_PDU> MQTT message
+  //
+  //  Parameters:
+  //    pl_message  - *in* <EPTF_MQTT_PDU> - received MQTT message
+  ///////////////////////////////////////////////////////////
   type function fcb_EPTF_MQTT_Transport_receiveMessage(in EPTF_MQTT_PDU pl_message) runs on self;
+
+  ///////////////////////////////////////////////////////////
+  //  Type: fcb_EPTF_MQTT_Transport_receiveEvent
+  //
+  //  Purpose:
+  //    Call-back function type for reporting received <ASP_Event> MQTT event
+  //
+  //  Parameters:
+  //    p_event  - *in* <ASP_Event> - received MQTT event
+  ///////////////////////////////////////////////////////////
   type function fcb_EPTF_MQTT_Transport_receiveEvent(in ASP_Event p_event) runs on self;
+  
+  ///////////////////////////////////////////////////////////
+  //  Type: fcb_EPTF_MQTT_Transport_sendMessage
+  //
+  //  Purpose:
+  //    Call-back function type for sending a <EPTF_MQTT_PDU> MQTT message
+  //
+  //  Parameters:
+  //    pl_msg  - *in* <EPTF_MQTT_PDU> - MQTT message to be sent
+  ///////////////////////////////////////////////////////////
   type function fcb_EPTF_MQTT_Transport_sendMessage(in EPTF_MQTT_PDU pl_msg) runs on self;
+  
+  ///////////////////////////////////////////////////////////
+  //  Type: fcb_EPTF_MQTT_Transport_apiRequest
+  //
+  //  Purpose:
+  //    Call-back function type for sending a <EPTF_MQTT_Transport_Request> MQTT transport request
+  //
+  //  Parameters:
+  //    pl_req  - *in* <EPTF_MQTT_Transport_Request> - MQTT transport request to be sent
+  ///////////////////////////////////////////////////////////
   type function fcb_EPTF_MQTT_Transport_apiRequest(in EPTF_MQTT_Transport_Request pl_req) runs on self;
+  
+  ///////////////////////////////////////////////////////////
+  //  Type: fcb_EPTF_MQTT_Transport_apiResponse
+  //
+  //  Purpose:
+  //    Call-back function type for reporting a <EPTF_MQTT_Transport_Response> MQTT transport response
+  //
+  //  Parameters:
+  //    pl_rsp  - *in* <EPTF_MQTT_Transport_Response> - MQTT transport response to be reported
+  ///////////////////////////////////////////////////////////
   type function fcb_EPTF_MQTT_Transport_apiResponse(in EPTF_MQTT_Transport_Response pl_rsp) runs on self;
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_PDU
+  //
+  //  Purpose:
+  //    Encapsulates a MQTT PDU with the corresponding entity (and FSM) indices and transport information
+  //
+  //  Parameters:
+  //    pdu - <MQTT_ReqResp> - MQTT PDU
+  //    transportParams - <EPTF_MQTT_TransportParameters> - transport protocol information
+  //    sessionIdx - *integer* - session index
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_PDU
   {
     MQTT_v3_1_1_ReqResp           pdu,
@@ -32,6 +139,17 @@
     integer                       sessionIdx
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_TransportParameters
+  //
+  //  Purpose:
+  //    Transport parameters for MQTT
+  //
+  //  Parameters:
+  //    localAddress - <Socket> - local address
+  //    remoteAddress - <Socket> - remote address
+  //    proto - <ProtoTuple> - IP transport protocol
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_TransportParameters
   {
     Socket      localAddress,
@@ -39,20 +157,42 @@
     ProtoTuple  proto
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_Request
+  //
+  //  Purpose:
+  //    Type for transport request
+  //
+  //  Elements:
+  //    sessionIdx - *integer* - session index
+  //    expectResponse - *boolean* - set to true if request execution result is expected to be reported back
+  //    params - <EPTF_MQTT_Transport_RequestParams> *optional* - parameters of the request
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_Transport_Request
   {
-	integer sessionIdx,
+    integer sessionIdx,
     boolean expectResponse,
     EPTF_MQTT_Transport_RequestParams params optional
   }
 
   const EPTF_MQTT_Transport_Request c_EPTF_MQTT_Transport_Request_init :=
   {
-	sessionIdx := -1,
+    sessionIdx := -1,
     expectResponse := true,
     params := omit
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_RequestParams
+  //
+  //  Purpose:
+  //    Union encapsulating the different transport requests
+  //
+  //  Elements:
+  //    startListening - <EPTF_MQTT_Transport_startListening> - starts a listening socket
+  //    connect_ - <EPTF_MQTT_Transport_connect> - connects to the remote address
+  //    close - <EPTF_MQTT_Transport_RequestParams> - closes the connection
+  ///////////////////////////////////////////////////////////
   type union EPTF_MQTT_Transport_RequestParams
   {
     EPTF_MQTT_Transport_startListening startListening,
@@ -60,26 +200,65 @@
     EPTF_MQTT_Transport_close          close
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_startListening
+  //
+  //  Purpose:
+  //    Starts a listening socket
+  //
+  //  Elements:
+  //    localAddress - <Socket> - local address of the listning socket
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_Transport_startListening
   {
     Socket localAddress
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_connect
+  //
+  //  Purpose:
+  //    Establishes a connection between the local and remote sockets
+  //
+  //  Elements:
+  //    localAddress - <Socket> - local address of the connection
+  //    remoteAddress - <Socket> - remote address of the connection
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_Transport_connect
   {
     Socket localAddress,
     Socket remoteAddress
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_close
+  //
+  //  Purpose:
+  //    Closes the connection
+  //
+  //  Elements:
+  //    localAddress - <Socket> - local address of the connection
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_Transport_close
   {
     Socket localAddress
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_Response
+  //
+  //  Purpose:
+  //    Type for transport response
+  //
+  //  Parameters:
+  //    succ - *boolean* - result request's execution
+  //    sessionIdx - *integer* - session index
+  //    params - <EPTF_MQTT_Transport_ResponseParams> *optional* - parameters of the response
+  ///////////////////////////////////////////////////////////
   type record EPTF_MQTT_Transport_Response
   {
     boolean succ,
-	integer sessionIdx,
+    integer sessionIdx,
     EPTF_MQTT_Transport_ResponseParams params optional
   }
 
@@ -90,12 +269,45 @@
     params := omit
   }
 
+  ///////////////////////////////////////////////////////////
+  //  Type: EPTF_MQTT_Transport_ResponseParams
+  //
+  //  Purpose:
+  //    Union encapsulating the responses
+  //
+  //  Elements:
+  //    listening - *boolean* - true if the listening socket was opened succesfully, false otherwise
+  //    connectionClose - <Socket> - indication of a closed connection with its address
+  ///////////////////////////////////////////////////////////
   type union EPTF_MQTT_Transport_ResponseParams
   {
     boolean listening,
-	Socket	connectionClosed
+    Socket connectionClosed
   }
 
+  /*****************************************************************
+   @startuml EPTF_MQTT_Transport_Definitions.EPTF_MQTT_Transport_Provider_CT.jpg
+     class EPTF_MQTT_Transport_Provider_CT {
+       fcb_EPTF_MQTT_Transport_receiveMessage vf_EPTF_MQTT_Transport_receiveMessage
+       fcb_EPTF_MQTT_Transport_receiveEvent fcb_EPTF_MQTT_Transport_receiveEvent
+       fcb_EPTF_MQTT_Transport_apiResponse vf_EPTF_MQTT_Transport_apiResponse
+     }
+   @enduml
+  *****************************************************************/
+  ///////////////////////////////////////////////////////////
+  // Type: EPTF_MQTT_Transport_Provider_CT
+  //
+  // Purpose:
+  //   Base component type for a MQTT transport realization, declares variables to register the transport user functions
+  //
+  // Class:
+  //   (see EPTF_MQTT_Transport_Definitions.EPTF_MQTT_Transport_Provider_CT.jpg)
+  //
+  // Variables:
+  //   vf_EPTF_MQTT_Transport_receiveMessage - <fcb_EPTF_MQTT_Transport_receiveMessage> - Function hook for reporting received messages
+  //   vf_EPTF_MQTT_Transport_receiveEvent - <fcb_EPTF_MQTT_Transport_receiveEvent> - Function hook for reporting received events
+  //   vf_EPTF_MQTT_Transport_apiResponse - <fcb_EPTF_MQTT_Transport_apiResponse> - Function hook for reporting transport API responses
+  ///////////////////////////////////////////////////////////
   type component EPTF_MQTT_Transport_Provider_CT
   {
     var fcb_EPTF_MQTT_Transport_receiveMessage  vf_EPTF_MQTT_Transport_receiveMessage := null;
@@ -103,6 +315,27 @@
     var fcb_EPTF_MQTT_Transport_apiResponse     vf_EPTF_MQTT_Transport_apiResponse := null;
   }
 
+  /*****************************************************************
+   @startuml EPTF_MQTT_Transport_Definitions.EPTF_MQTT_Transport_User_CT.jpg
+     class EPTF_MQTT_Transport_User_CT {
+       fcb_EPTF_MQTT_Transport_sendMessage vf_EPTF_MQTT_Transport_send
+       fcb_EPTF_MQTT_Transport_apiRequest vf_EPTF_MQTT_Transport_apiRequest
+     }
+   @enduml
+  *****************************************************************/
+  ///////////////////////////////////////////////////////////
+  // Type: EPTF_MQTT_Transport_User_CT
+  //
+  // Purpose:
+  //   Base component type for a MQTT transport user realization
+  //
+  // Class:
+  //   (see EPTF_MQTT_Transport_Definitions.EPTF_MQTT_Transport_User_CT.jpg)
+  //
+  // Variables:
+  //   vf_EPTF_MQTT_Transport_send - <fcb_EPTF_MQTT_Transport_sendMessage> - Function hook for reporting received messages
+  //   vf_EPTF_MQTT_Transport_apiRequest - <fcb_EPTF_MQTT_Transport_apiRequest> - Function hook for reporting received events
+  ///////////////////////////////////////////////////////////
   type component EPTF_MQTT_Transport_User_CT
   {
     var fcb_EPTF_MQTT_Transport_sendMessage     vf_EPTF_MQTT_Transport_send := null;
diff --git a/test/EPTF_MQTT_Tests.ttcn b/test/EPTF_MQTT_Tests.ttcn
index 968e17c..989ab19 100644
--- a/test/EPTF_MQTT_Tests.ttcn
+++ b/test/EPTF_MQTT_Tests.ttcn
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 //
-// Copyright (c) 2000-2019 Ericsson Telecom AB
+// Copyright (c) 2000-2020 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
@@ -9,11 +9,20 @@
 ///////////////////////////////////////////////////////////////////////////////
 //  File:               EPTF_MQTT_Tests.ttcn
 //  Description:
-//  Rev:                R1A
+//  Rev:                <RnXnn>
 //  Prodnr:             CNL 113 860
 //  Updated:            2017-09-01
 //  Contact:            http://ttcn.ericsson.se
 ///////////////////////////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////
+//  Module: EPTF_MQTT_Tests
+// 
+//  Purpose:
+//    This module contains the component tests for the EPTF MQTT Applib
+// 
+///////////////////////////////////////////////////////////////
 module EPTF_MQTT_Tests {
 
 }