DICOM medical graphics processing: storescp.exeand storescu.exe source code analysis, learning C-STORE request (continued)

Source: Internet
Author: User
Background:

In the previous blog, In the storescp tool source file storescp. source File SCP of the CC and dcmscp classes. after the analysis of CC, it is concluded that both of them can respond to the C-ECHO and C-STORE (need to extend the dcmscp class) Request function. However, when you expand the dcmscpcategory, you may encounter a problem when simulating the actual storescp.exe tool. The client prompts a service interruption link, and the server displays a failure in saving the file, as shown in. This blog post again compares storescp. CC and SCP. CC by eliminating this issue, focusing on presentation context, abstractsyntax, transfersyntax and other details, and earnestly studying DICOM communication services.

Troubleshooting: the debugging information of the storescp.exe toolkit and the custom toolkit is analyzed in 1 ).

Debugging information of the Consumer Client. Compare with the debugging information of the custom tool server.


Debugging information in comparison, whereRed partThe end A-ASSOCIATE-AC indicates that the server has successfully finished handshaking with the client, that is, the network has successfully responded to the client connection.Blue partIndicates that the C-STORE-RQ request sent by the client has successfully reached the server, the only difference isYellow circle markIt indicates that there is a problem with the processing of the C-STORE-RQ request after the server receives it. The zsdcmstorescpclass we installed is the storescp and storescpcallback functions in the directly stored storescp.exe tool. Therefore, we can roughly determine the scope of the problem.

2) single-step debugging

The handleincomingcommand function calls the storescp command to insert a breakpoint and enter the single-step debugging status. Using the new debugging tool "parallel stack" provided by vs2012, the first return state cond. Bad () is "true", that is, the function asc_findacceptedpresentationcontext, as shown in:

Continue one-step debugging and go to the asc_findacceptedpresentationcontext function. The findpresentationcontextid is the real error.The presentationcontextid parameter is always zero.

Guess:It may be that the presentationcontextid parameter has an error in a certain part of the transfer process, causing the program to fail. To verify our ideas, open the storescp.exeproject, enter the model, and the numeric conditions of the program. As shown in, the value of presentationcontextid in the storescp.exe toolkit is 41. Therefore, it is proved that an error occurred while the presentationcontextid parameter was passed.

3) parameter transfer flow

In order to determine the error link in the specific transfer process, we adopt the Backtracking Method to Determine the specific location of the problem by backtracking the source of the presentationcontextid parameter in the findpresentationcontextid function.


(Note: For convenience, the image has been rotated for 90 degrees, so you may have to look at it with your neck)

The comparison is implemented in the pipeline. Check the code carefully and findMajor problemsWhen we split the content of the processcommands function in storescp.exe into the handleincomingcommand function, we commented out the redundant dimse_receivecommand function,Commented out the t_asc_association local variable.So that the presid variable that should have been obtained through the dimse_receivecommand function has been overwritten by the local variable as 0 -- so far the problem is found.

So because the redundant dimse_receivecommand function is commented out, where can we get the presid parameter. Check the header of the handleincomingcommand function. No parameter of the t_asc_presentationcontextid type is displayed in the function parameters. However, compared with the handleechorequest function of SCP. CC, we found that the presid value is stored in the dcmpresentationcontextinfo type presinfo variable in the SCP. CC class. Therefore, we modify the storescp call and pass presinfo. presentationcontextid to the initial value as the presid.

After the modification is complete, debug again and find that the program runs normally, the client successfully received the DIMSE messagefrom the server, and in the service directory, it also saw the DCM file passed by storescu.exe (of course, the file was renamed within the storescp function based on time and other information ).


The functions of the fuse toolkit.

Summary:

During the debugging and troubleshooting process, we found that the detailed section should be paid special attention to when combining the code for transferring different files. By the way, the t_asc_association type parameter is lost in this transmission. We will analyze in detail the role of the t_asc_associaton type parameter that fails to be passed,Why does a simple passing of a parameter cause failure of the C-STORE function?

1) Presentation context, abstractsyntax, and transfersyntax details

In the previous blog, we extracted the interpretations of presentation context, abstractsyntax, and transfersyntax in the dicom3.0 standard. Generally speaking, presentation context represents two application entities (AE = applicaiton entity) the interactive environment (usually called context) contains the following abstractsyntax and transfersyntax terms. Abstractsyntax and transfersyntax are easy to confuse because the English words contain syntax,Actually, the two are completely different concepts.Abstractsyntax focuses on the upper layer information, that is, the interaction between the two interactive AE, that is, the type of the service object pair (SOP) mentioned in the standard, by viewing dcuid. according to the hfile, abstractsyntax hasStore, query/Retrive, worklistFor exampleUid_ctimagestorageQuery/retrive typeUid_findpatientrootqueryretrieveinformationmodel, Worklist typeUid_findmodalityworklistinformationmodelAnd so on. These are the several types of services we often use in C-Echo, C-store, C-FIND services; while transfersyntax focuses on the encoding rules of information transmission interaction,Whether it is explicit or implicit, littleendian or bigendian, Common includeUid_littleendianimplicittransfersyntax, uid_littleendianexplicittransfersyntaxAnd so on. You can view the details on your own.Dcuid. hFile. The missing presid parameter passed above includes the two most important interaction information. As a result, the entire C-STORE service fails.

2) Comparison between storescp. CC and SCP. CC

The storescp.exe toolkit and dcmscp class areWhat time? Where can I set these parameters?Next we will compare and analyze the implementation process of the two tools again (details can refer to the previous blog DICOM medical image processing: storescp.exeand storescu.exe source code analysis, learning C-STORE requests ).

2.1 SCP. CC source code file

Use the image of the previous blog to analyze the specific operations on the presentation context (namely, abstractsyntax and transfersyntax) in the dcmscp class.


The specific location and function used to set the presentation context in the dcmscp class are provided.

2.2 storescp.exe source code file

The setup process in the storescp.exe toolkit is similar. Next, we will analyze it using the diagram of the previous blog.


By comparing the two images, we can find that both dcmscpand storescp.exe configure the context of the connected presentation context before processing the real DIMSE message. As for so many UIDs (both abstractsyntax and transfersyntax are in dcuid. the uniform uid is used in the hfile)Where is the storage?Or m_assoc (in the dcmscp class), check the definition of the t_asc_association type and open it step by step. We can see that, as we expected, this variable stores all the UID of the connection context, as shown in:


Therefore, we have finally come to an end with an analysis of the source code of the dcmscpcategory and storescp.exe tools. We hope you will have a deeper understanding of DICOM network communication services.

3) Preliminary conjecture on the Implementation of dcmscp and dcmstorescp in the new DCMTK version

Through the use of dcmscp class engineering found that the design of this class is somewhat inadequate, open interface is not reasonable enough, can not easily implement expansion to respond to C-STORE and other requests. I guess the new DCMTK version will be modified. By checking the official instructions of dcmtk3.6.1, I found that the new DCMTK open-source library does make significant changes to the dcmscp and dcmscu base classes, many new interfaces (such as) are opened to facilitate user expansion. In addition, the new Library provides encapsulatedDcmstorescp and dcmstorescuSo you should not use the zsdcmstorescp class I have provided. It is only for testing. To use it, please install the latest DCMTK open source library.

Download the instance project code:
1) download csdn resources:

Connection: http://download.csdn.net/detail/zssureqh/7870789,1.

2) GitHub Free Download

Connection: https://github.com/zssure-thu/CSDN

Subsequent blog posts:

1) dcmtk3.6.0 dcmscp and dcmtk3.6.1 dcmscp analysis, and dcmstorescp and dcmstorescu usage of dcmtk3.6.1

2) Different design modes of DCMTK and Fo-DICOM file storage: single thread vs multi-thread

3366wlmscpfs.exeand findscu.exe source code analysis: Learning C-FIND request


[Email protected]

Time: 2014-09-13


DICOM medical graphics processing: storescp.exeand storescu.exe source code analysis, learning C-STORE request (continued)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.