MPPS NCREATE error

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
rvillar
Posts: 2
Joined: Tue, 2020-06-09, 08:05

MPPS NCREATE error

#1 Post by rvillar »

I have a C++ SCU function that prepares an MPPS "IN PROGRESS" message/dataset and sends it to an SCP. The SCP is a DICOM validation tool made by the DVTK company. The DVTK software validated the message/dataset is correct and it has prepared a response message to send back but it reports a problem when attempting to send it. It appears that my function has somehow closed the TCP connection before receiving the response. All of my other functions are working well but this function is using the NCREATE and NSET protocol. When use the debugger to step into the DCMTK source code I can see that it disconnected because the event and state machine told it to disconnect.

Can you please review my SCU function and log and let me know if there is something obvious that I did wrong.

Below is my C++ function

bool CDicomScu::SendMPPS(_in DcmDataset &dataset, _out_opt OFCondition *pRtnStatus /* = nullptr */)
{
bool bRtn = false;

OFCondition Status;

if (pRtnStatus)
*pRtnStatus = EC_Normal;


// dataset.print(std::cout);

const char *pSOPInstanceUID = nullptr;
dataset.findAndGetString(DCM_SOPInstanceUID, pSOPInstanceUID);

if (!pSOPInstanceUID)
return bRtn;

QString sSOPInstanceUID = pSOPInstanceUID;

const char *pPerformedProcedureStepStatus = nullptr;
dataset.findAndGetString(DCM_PerformedProcedureStepStatus, pPerformedProcedureStepStatus);

if (!pPerformedProcedureStepStatus)
return bRtn;


if (!SetConnectionData())
return bRtn;

// Setup the transfer syntax.
OFList<OFString> ts;
GetTransferSyntax(ts);

// Setup the presentation context; what service you are requesting.
addPresentationContext(UID_ModalityPerformedProcedureStepSOPClass, ts);

// Initialize the network; setup Winsock.
Status = initNetwork();

if (Status.good())
{
// Contact PACS/MWL and negotiate network settings and SOP.
Status = negotiateAssociation();

if (Status.good())
{
// Get the accepted negotiation.
T_ASC_PresentationContextID PresContextID = FindUncompressedPC(UID_ModalityPerformedProcedureStepSOPClass);

if (PresContextID > 0)
{
// Assemble the message.
T_DIMSE_Message msg;
memset(reinterpret_cast<void*>(&msg), 0, sizeof(msg));

OFString sAbstractSyntax, sTransferSyntax;
T_DIMSE_Command eExpectedResponse;
Uint16 nExpectedMessageID = 0;

if (strcmp(pPerformedProcedureStepStatus, "IN PROGRESS") == 0)
{
eExpectedResponse = DIMSE_N_CREATE_RSP;
T_DIMSE_N_CreateRQ *pReq = &(msg.msg.NCreateRQ);
msg.CommandField = DIMSE_N_CREATE_RQ;
nExpectedMessageID = pReq->MessageID = nextMessageID();
pReq->DataSetType = DIMSE_DATASET_PRESENT;
pReq->opts = O_NCREATE_AFFECTEDSOPINSTANCEUID;
findPresentationContext(PresContextID, sAbstractSyntax, sTransferSyntax);
strcpy_s(pReq->AffectedSOPClassUID, sAbstractSyntax.c_str());
strcpy_s(pReq->AffectedSOPInstanceUID, sSOPInstanceUID.toUtf8().constData());


}
else
{
eExpectedResponse = DIMSE_N_SET_RSP;
T_DIMSE_N_SetRQ *pReq = &(msg.msg.NSetRQ);
msg.CommandField = DIMSE_N_SET_RQ;
nExpectedMessageID = pReq->MessageID = nextMessageID();
pReq->DataSetType = DIMSE_DATASET_PRESENT;
findPresentationContext(PresContextID, sAbstractSyntax, sTransferSyntax);
strcpy_s(pReq->RequestedSOPClassUID, sAbstractSyntax.c_str());
strcpy_s(pReq->RequestedSOPInstanceUID, sSOPInstanceUID.toUtf8().constData());
}

Status = sendDIMSEMessage(PresContextID, &msg, &dataset);

if (Status.good())
{
DcmDataset *pStatusDetail = nullptr;
T_DIMSE_Message responseMsg;
memset(reinterpret_cast<void*>(&responseMsg), 0, sizeof(responseMsg));

Status = receiveDIMSECommand(&PresContextID, &responseMsg, &pStatusDetail, nullptr);

if (responseMsg.CommandField == eExpectedResponse)
{
T_ASC_PresentationContextID tempID;
DcmDataset *pTempDataset = nullptr;
bool bGetUnexpectedDataset = false;

// Check whether there is a dataset to be received.
// This should never happen.
if (responseMsg.CommandField == DIMSE_N_CREATE_RSP && responseMsg.msg.NCreateRSP.DataSetType == DIMSE_DATASET_PRESENT)
bGetUnexpectedDataset = true;

if (responseMsg.CommandField == DIMSE_N_SET_RSP && responseMsg.msg.NSetRSP.DataSetType == DIMSE_DATASET_PRESENT)
bGetUnexpectedDataset = true;

if (bGetUnexpectedDataset)
{
DCMNET_WARN("Trying to retrieve unexpected dataset in response");
if (receiveDIMSEDataset(&tempID, &pTempDataset).good())
{
DCMNET_WARN("Received unexpected dataset after response, ignoring");
delete pTempDataset;
pTempDataset = nullptr;
}
}

// if response contains SOP Instance UID, copy it.
if (responseMsg.msg.NCreateRSP.opts & O_NCREATE_AFFECTEDSOPINSTANCEUID)
{
sSOPInstanceUID = responseMsg.msg.NCreateRSP.AffectedSOPInstanceUID;
}


bRtn = (Status.good() ? true : false);
}
else
{
DCMNET_WARN("Recieved unexpected response");
}

if (pStatusDetail)
{
delete pStatusDetail;
pStatusDetail = nullptr;
}

}
}
}
releaseAssociation();
freeNetwork();
}

if (pRtnStatus)
*pRtnStatus = Status;

return bRtn;
}



Below is a section of my log. It contains the error at the end of the log.

D: Configured a total of 1 presentation contexts for SCU
I: Request Parameters:
I: ====================== BEGIN A-ASSOCIATE-RQ =====================
I: Our Implementation Class UID: 1.3.6.1.4.1.53599.0.3.6.3
I: Our Implementation Version Name: OFFIS_DCMTK_363
I: Their Implementation Class UID:
I: Their Implementation Version Name:
I: Application Context Name: 1.2.840.10008.3.1.1.1
I: Calling Application Name: CanfieldSCU1
I: Called Application Name: DVTK_MWL_SCP
I: Responding Application Name: DVTK_MWL_SCP
I: Our Max PDU Receive Size: 16384
I: Their Max PDU Receive Size: 0
I: Presentation Contexts:
I: Context ID: 1 (Proposed)
I: Abstract Syntax: =ModalityPerformedProcedureStepSOPClass
I: Proposed SCP/SCU Role: Default
I: Proposed Transfer Syntax(es):
I: =LittleEndianImplicit
I: Requested Extended Negotiation: none
I: Accepted Extended Negotiation: none
I: Requested User Identity Negotiation: none
I: User Identity Negotiation Response: none
I: ======================= END A-ASSOCIATE-RQ ======================
I: Requesting Association
I: DUL FSM Table: State: 1 Event: 0
I: DUL Event: A-ASSOCIATE request (local user)
I: DUL Action: AE 1 Transport Connect
D: setting network send timeout to 60 seconds
D: setting network receive timeout to 60 seconds
I: DUL FSM Table: State: 4 Event: 1
I: DUL Event: Transport conn confirmation (local)
I: DUL Action: AE 2 Send Associate RQ PDU
D: Constructing Associate RQ PDU
I: DUL FSM Table: State: 5 Event: 2
I: DUL Event: A-ASSOCIATE-AC PDU (on transport)
I: DUL Action: AE 3 Associate Confirmation Accept
D: PDU Type: Associate Accept, PDU Length: 175 + 6 bytes PDU header
D: 02 00 00 00 00 af 00 01 00 00 44 56 54 4b 5f 4d
D: 57 4c 5f 53 43 50 20 20 20 20 43 61 6e 66 69 65
D: 6c 64 53 43 55 31 20 20 20 20 00 00 00 00 00 00
D: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
D: 00 00 00 00 00 00 00 00 00 00 10 00 00 15 31 2e
D: 32 2e 38 34 30 2e 31 30 30 30 38 2e 33 2e 31 2e
D: 31 2e 31 21 00 00 19 01 00 00 00 40 00 00 11 31
D: 2e 32 2e 38 34 30 2e 31 30 30 30 38 2e 31 2e 32
D: 50 00 00 31 51 00 00 04 00 00 40 00 52 00 00 1c
D: 31 2e 32 2e 38 32 36 2e 30 2e 31 2e 33 36 38 30
D: 30 34 33 2e 32 2e 31 35 34 35 2e 33 55 00 00 05
D: 33 2e 30 2e 30
D: Parsing an A-ASSOCIATE PDU
I: Association Parameters Negotiated:
I: ====================== BEGIN A-ASSOCIATE-AC =====================
I: Our Implementation Class UID: 1.3.6.1.4.1.53599.0.3.6.3
I: Our Implementation Version Name: OFFIS_DCMTK_363
I: Their Implementation Class UID: 1.2.826.0.1.3680043.2.1545.3
I: Their Implementation Version Name: 3.0.0
I: Application Context Name: 1.2.840.10008.3.1.1.1
I: Calling Application Name: CanfieldSCU1
I: Called Application Name: DVTK_MWL_SCP
I: Responding Application Name: DVTK_MWL_SCP
I: Our Max PDU Receive Size: 16384
I: Their Max PDU Receive Size: 16384
I: Presentation Contexts:
I: Context ID: 1 (Accepted)
I: Abstract Syntax: =ModalityPerformedProcedureStepSOPClass
I: Proposed SCP/SCU Role: Default
I: Accepted SCP/SCU Role: Default
I: Accepted Transfer Syntax: =LittleEndianImplicit
I: Requested Extended Negotiation: none
I: Accepted Extended Negotiation: none
I: Requested User Identity Negotiation: none
I: User Identity Negotiation Response: none
I: ======================= END A-ASSOCIATE-AC ======================
I: Association Accepted (Max Send PDV: 16372)
I: DUL FSM Table: State: 6 Event: 8
I: DUL Event: P-DATA request primitive
I: DUL Action: DT 1 Send P DATA PDU
I: DUL FSM Table: State: 6 Event: 8
I: DUL Event: P-DATA request primitive
I: DUL Action: DT 1 Send P DATA PDU
I: DUL FSM Table: State: 6 Event: 16
I: DUL Event: Transport connection closed
I: DUL Action: AA 4 Indicate AP Abort
W: Recieved unexpected response
I: Releasing Association
I: DUL FSM Table: State: 1 Event: 10
I: DUL Event: A-RELEASE request primitive
I: DUL Action:
E: Association Release Failed: 0006:0303 DUL Finite State Machine Error: No action defined, state 1 event 10
D: Cleaning up internal association and network structures
2020-06-10T07:53:57.754 Error QTcpMessageUtil::addErrorToList - Failed to send MWL/MPPS message. Status:INPROGRESS|DateTime:2020-06-10T07:53:54|MRN: pidP645|Name: One^Secondary Capture Image
2020-06-10T07:53:57.835 Error QTcpMessageUtil::addErrorToList - Failed to process.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1444
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: MPPS NCREATE error

#2 Post by Marco Eichelberg »

It seems to me that the DVTk SCP for some reason closes the transport connection unexpectedly, as this line seems to indicate:

Code: Select all

DUL Action: AA 4 Indicate AP Abort
. This is a "provider abort", i.e. what happens when DCMTK discovers that suddenly the network connection is gone without have been properly closed with A-RELEASE or A-ABORT. It might be worthwhile to capture this using Wireshark and confirm whether there is really a problem on DVTk's side.

rvillar
Posts: 2
Joined: Tue, 2020-06-09, 08:05

Re: MPPS NCREATE error

#3 Post by rvillar »

Thank you for the advice. I will use the WireShark software to debug this issue.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest