Skip to content

Commit

Permalink
Ticket #318 : PD Request - sequence counter not incremented
Browse files Browse the repository at this point in the history
Because the PD_ELE_T entry for PD Requests is removed from the PD Send Queue as soon as it is sent, hence for maintaining the last used sequence counter, a list of last sequence counter used per each comId for PD Requests is maintained. The pointer to the first element in the list is added in the TRDP_SESSION struct. Every time a new PD request is to be sent, the last sequence counter used for that comId is fetched from this list.

git-svn-id: https://svn.code.sf.net/p/tcnopen/trdp/trunk@2162 3b5a3598-5f4e-4449-9e63-bd40438bfec0
  • Loading branch information
ckhangani committed Apr 6, 2020
1 parent d21895b commit e1b1604
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
39 changes: 32 additions & 7 deletions trdp/src/common/tlp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/*
* $Id$
*
* CK 2020-04-06: Ticket #318 PD Request - sequence counter not incremented
* SB 2020-03-30: Ticket #311: replaced call to trdp_getSeqCnt() with -1 because redundant publisher should not run on the same interface
* BL 2019-12-06: Ticket #300 Can error message in tlp_setRedundant() be changed to warning?
* BL 2019-10-25: Ticket #288 Why is not tlm_reply() exported from the DLL
Expand Down Expand Up @@ -1016,9 +1017,10 @@ EXT_DECL TRDP_ERR_T tlp_request (
UINT32 replyComId,
TRDP_IP_ADDR_T replyIpAddr)
{
TRDP_ERR_T ret = TRDP_NO_ERR;
PD_ELE_T *pSubPD = (PD_ELE_T *) subHandle;
PD_ELE_T *pReqElement = NULL;
TRDP_ERR_T ret = TRDP_NO_ERR;
PD_ELE_T *pSubPD = (PD_ELE_T *) subHandle;
PD_ELE_T *pReqElement = NULL;
TRDP_PR_SEQ_CNT_LIST_T *pListElement = NULL;

/* Check params */
if ((appHandle == NULL)
Expand Down Expand Up @@ -1128,10 +1130,33 @@ EXT_DECL TRDP_ERR_T tlp_request (
pReqElement->pktFlags =
(pktFlags == TRDP_FLAGS_DEFAULT) ? appHandle->pdDefault.flags : pktFlags;
pReqElement->magic = TRDP_MAGIC_PUB_HNDL_VALUE;
/* Find a possible redundant entry in one of the other sessions and sync
the sequence counter! curSeqCnt holds the last sent sequence counter,
therefore set the value initially to -1, it will be incremented when sending... */
pReqElement->curSeqCnt = 0xFFFFFFFF;

/* Get the sequence counter from the sequence list maintained per comId.. */
pListElement = appHandle->pSeqCntList4PDReq;
while (pListElement)
{
if (pListElement->comId == comId)
{
/* Entry found */
break;
}
pListElement = pListElement->pNext;
}

/* Add entry if not present */
if (!pListElement)
{
pListElement = (TRDP_PR_SEQ_CNT_LIST_T *)vos_memAlloc(sizeof(TRDP_PR_SEQ_CNT_LIST_T));
pListElement->comId = comId;
pListElement->lastSeqCnt = 0xFFFFFFFFu;
pListElement->pNext = appHandle->pSeqCntList4PDReq;
appHandle->pSeqCntList4PDReq = pListElement;
}

/* Sequence counter is incremented once before sending in PD send */
pReqElement->curSeqCnt = pListElement->lastSeqCnt;
pListElement->lastSeqCnt++;

/* Enter this request into the send queue. */
trdp_queueInsFirst(&appHandle->pSndQueue, pReqElement);
}
Expand Down
10 changes: 10 additions & 0 deletions trdp/src/common/trdp_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/*
* $Id$
*
* CK 2020-04-06: Ticket #318 Added pointer to list of seqCnt used per comId for PD Requests in TRDP_SESSION_T
* SB 2020-03-30: Ticket #309 Added pointer to a Session's Listener
* BL 2020-02-26: Ticket #319 Protocol Version is defined twice
* AÖ 2020-01-10: Ticket #293 Minor fix in the macro, added spaces to avoid " to be part of the final string.
Expand Down Expand Up @@ -195,6 +196,14 @@ typedef struct
TRDP_SEQ_CNT_ENTRY_T seq[1]; /**< list of used sequence no. */
} TRDP_SEQ_CNT_LIST_T;

/** Tuple of last used sequence counter for PD Request (PR) per comId */
typedef struct TRDP_PR_SEQ_CNT_ELE
{
struct TRDP_PR_SEQ_CNT_ELE *pNext; /**< pointer to next element or NULL */
UINT32 comId; /**< comId for PR to send */
UINT32 lastSeqCnt; /**< Sequence counter value for comId */
} TRDP_PR_SEQ_CNT_LIST_T;

/** TCP parameters */
typedef struct TRDP_SOCKET_TCP
{
Expand Down Expand Up @@ -433,6 +442,7 @@ typedef struct TRDP_SESSION
PD_ELE_T *pSndQueue; /**< pointer to first element of send queue */
PD_ELE_T *pRcvQueue; /**< pointer to first element of rcv queue */
PD_PACKET_T *pNewFrame; /**< pointer to received PD frame */
TRDP_PR_SEQ_CNT_LIST_T *pSeqCntList4PDReq; /**< pointer to list of sequence counters for PR per comId */
TRDP_TIME_T initTime; /**< initialization time of session */
TRDP_STATISTICS_T stats; /**< statistics of this session */
#ifdef HIGH_PERF_INDEXED
Expand Down

0 comments on commit e1b1604

Please sign in to comment.