DICOM Networking - Service Classes

Section 11 of 27
41% complete

DICOM networking enables communication between medical imaging devices. This section covers the fundamental concepts of DICOM network operations.

Understanding Service Classes

DICOM service classes define specific network operations. Each service class combines:

Service Class Componentssaravanansubramanian.coma SOP Class is the shared contract; SCU is the client, SCP is the serverSOP CLASS (shared contract)Information ObjectDefinition (IOD)what data is transmittedDIMSE Serviceshow the operation worksC-STORE · C-FIND · C-ECHO …implemented byimplemented byService Class UserSCU · clientinitiates the associationsends requestse.g. modality sending imagesService Class ProviderSCP · serveraccepts associationsresponds to requestse.g. PACS receiving imagesDIMSE messages

Common Service Classes

Each service class has a unique UID that identifies its capabilities. Store these UIDs as constants to reference them when configuring presentation contexts for network associations.

public static class DicomServiceClasses
{
    // Verification Service Class (C-ECHO)
    public const string Verification = "1.2.840.10008.1.1";

    // Storage Service Classes
    public const string CTImageStorage = "1.2.840.10008.5.1.4.1.1.2";
    public const string MRImageStorage = "1.2.840.10008.5.1.4.1.1.4";
    public const string USImageStorage = "1.2.840.10008.5.1.4.1.1.6.1";
    public const string SecondaryCaptureStorage = "1.2.840.10008.5.1.4.1.1.7";

    // Query/Retrieve Service Classes
    public const string StudyRootQueryRetrieve = "1.2.840.10008.5.1.4.1.2.2.1";
    public const string PatientRootQueryRetrieve = "1.2.840.10008.5.1.4.1.2.1.1";

    // Modality Worklist
    public const string ModalityWorklistFind = "1.2.840.10008.5.1.4.31";

    // Print Management
    public const string BasicGrayscalePrint = "1.2.840.10008.5.1.1.9";
}

DICOM Association

An association is a network connection between two DICOM applications. Before performing any DICOM operations, you must establish an association by negotiating capabilities with the remote system. The association defines which operations are permitted and how data will be encoded during the session.

Association Lifecycle

Understanding the association lifecycle helps troubleshoot connection issues. Each phase can fail independently, so knowing where in the process a failure occurs guides diagnosis.

DICOM Association Lifecyclesaravanansubramanian.comfour stages between requestor and acceptor bracket every DIMSE exchangeRequestorSCU · initiates connectionAcceptorSCP · listens for connectionsA-ASSOCIATE requestproposes AE Titles and presentation contexts1A-ASSOCIATE response (accept)acceptor selects which contexts it will honor2Data TransferC-STORE · C-FIND · C-MOVE · C-GET · C-ECHO3A-RELEASEgraceful shutdown — both sides confirm4

Establishing an Association

The following example demonstrates creating and opening a DICOM association. Always configure appropriate timeout values for your network environment and handle exceptions gracefully to provide meaningful error feedback.

public class DicomAssociationExample
{
    public void EstablishAssociation()
    {
        // Create association configuration
        DicomAssociation association = new DicomAssociation
        {
            CallingAETitle = "MY_SCU",          // Your application's AE Title
            CalledAETitle = "REMOTE_SCP",       // Remote server's AE Title
            Host = "192.168.1.100",             // Server IP address
            Port = 104,                         // DICOM standard port
            MaxPDULength = 65536                // Maximum Protocol Data Unit size
        };

        // Add presentation contexts
        // Each presentation context specifies:
        // - What you want to do (Abstract Syntax = SOP Class)
        // - How you want to encode data (Transfer Syntax)

        association.AddPresentationContext(
            DicomServiceClasses.CTImageStorage,            // Abstract Syntax
            CommonTransferSyntaxes.ExplicitVRLittleEndian  // Transfer Syntax
        );

        // Can add multiple presentation contexts
        association.AddPresentationContext(
            DicomServiceClasses.MRImageStorage,
            CommonTransferSyntaxes.ExplicitVRLittleEndian
        );

        try
        {
            // Open the association
            association.Open();
            Console.WriteLine("Association established successfully");

            // Perform DICOM operations here...

        }
        catch (DicomException ex)
        {
            Console.WriteLine($"Association failed: {ex.Message}");
        }
        finally
        {
            // Always close the association when done
            if (association.IsOpen)
            {
                association.Close();
            }
        }
    }
}

Presentation Context Negotiation

Presentation context negotiation determines which operations can be performed over the association. The SCU proposes combinations of SOP Classes and Transfer Syntaxes, and the SCP accepts or rejects each one. Operations can only be performed for accepted presentation contexts.

Presentation Context Negotiationsaravanansubramanian.comthe SCU proposes SOP Class + Transfer Syntax combinations; the SCP accepts or rejects eachSCU proposesService Class User · initiates the associationSCP respondsService Class Provider · picks one transfer syntax per contextCTX 1Abstract Syntax: CT Image StorageTransfer Syntaxes offeredExplicit VR Little EndianImplicit VR Little EndianJPEG 2000 LosslessSCP will pick one of these threeCTX 2Abstract Syntax: MR Image StorageTransfer Syntaxes offeredExplicit VR Little EndianImplicit VR Little EndianSCP does not support MR Storage at allCTX 1ACCEPTEDSelected Transfer SyntaxExplicit VR Little EndianCT storage may now be performed on this associationCTX 2REJECTEDRejection reasonAbstract Syntax Not SupportedRuleOperations may only be issued for contexts that were ACCEPTED — an SCU that ignores this will see its DIMSE requests rejected mid-association.

Application Entities (AEs)

AEs are DICOM network endpoints identified by AE Title, IP address, and port. Every DICOM device on a network must have a unique AE Title within its domain to prevent communication conflicts. AE Titles serve as identifiers for access control and routing decisions in PACS systems.

AE Configuration

Configure AE information for both local and remote endpoints. Proper validation of AE Title format prevents runtime errors during association negotiation.

public class DicomApplicationEntity
{
    public string AETitle { get; set; }      // 16 characters max
    public string HostName { get; set; }      // IP or hostname
    public int Port { get; set; }             // TCP port

    public DicomApplicationEntity(string aeTitle, string host, int port)
    {
        // Validate AE Title
        if (string.IsNullOrEmpty(aeTitle) || aeTitle.Length > 16)
        {
            throw new ArgumentException("AE Title must be 1-16 characters");
        }

        AETitle = aeTitle.ToUpper(); // AE Titles are typically uppercase
        HostName = host;
        Port = port;
    }
}

// Example configurations
var localAE = new DicomApplicationEntity("MY_SCU", "localhost", 11112);
var remoteAE = new DicomApplicationEntity("PACS_SERVER", "192.168.1.100", 104);

AE Title Rules

AE Title Requirements
=====================

Length:     1 to 16 characters
Characters: A-Z, 0-9, space, underscore
Case:       Case-sensitive (typically uppercase)
Trailing:   Trailing spaces are significant

Valid:
  "PACS_SERVER"
  "CT_SCANNER_1"
  "MY SCU"
  "TEST"

Invalid:
  "THIS_IS_TOO_LONG_AE_TITLE"  (>16 chars)
  "my-scu"                     (hyphen not allowed)
  "pacs@server"                (@ not allowed)

C-ECHO Service (Verification)

C-ECHO verifies DICOM connectivity - it’s the equivalent of a network “ping”. Use C-ECHO to confirm basic connectivity before attempting more complex operations like storage or query/retrieve. It validates that the association can be established and that the remote system responds to DICOM requests.

Implementing C-ECHO

The verification service implementation below establishes an association, sends a C-ECHO request, and interprets the response. This pattern forms the foundation for implementing other DIMSE services.

public class DicomVerificationService
{
    public bool PerformEcho(string callingAE, string calledAE, string host, int port)
    {
        DicomAssociation association = new DicomAssociation
        {
            CallingAETitle = callingAE,
            CalledAETitle = calledAE,
            Host = host,
            Port = port
        };

        // Add Verification SOP Class presentation context
        association.AddPresentationContext(
            DicomUID.VerificationSOPClass,
            DicomTransferSyntax.ExplicitVRLittleEndian
        );

        try
        {
            association.Open();

            // Create C-ECHO request
            DicomCommandSet request = new DicomCommandSet(DicomCommandType.C_ECHO_RQ);
            request.AffectedSOPClassUID = DicomUID.VerificationSOPClass;
            request.MessageID = 1;

            // Send request and get response
            DicomCommandSet response = association.SendRequest(request, null);

            bool success = response.Status == 0;

            if (success)
            {
                Console.WriteLine("C-ECHO successful");
            }
            else
            {
                Console.WriteLine($"C-ECHO failed: Status = 0x{response.Status:X4}");
            }

            return success;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"C-ECHO error: {ex.Message}");
            return false;
        }
        finally
        {
            if (association.IsOpen)
            {
                association.Close();
            }
        }
    }
}

C-ECHO Status Codes

StatusMeaning
0x0000Success
0x0122SOP Class not supported
0x0210Duplicate invocation
0x0211Unrecognized operation
0x0212Mistyped argument

Usage Example

The following example shows how to use the verification service in application startup or connectivity testing scenarios. Consider implementing periodic C-ECHO checks to monitor PACS availability.

// Test DICOM connectivity
var verifier = new DicomVerificationService();

bool connected = verifier.PerformEcho(
    callingAE: "MY_APP",
    calledAE: "PACS_SERVER",
    host: "192.168.1.100",
    port: 104
);

if (connected)
{
    Console.WriteLine("PACS server is reachable");
}
else
{
    Console.WriteLine("Cannot connect to PACS server");
}

Network Configuration Summary

DICOM Network Setup Checklist
=============================

1. AE Configuration:
   □ AE Title defined (1-16 characters)
   □ IP address configured
   □ Port number assigned (default: 104)

2. Firewall Rules:
   □ TCP port open for DICOM traffic
   □ Bidirectional traffic allowed

3. Association Settings:
   □ Timeout values configured
   □ Maximum PDU length set
   □ Supported SOP Classes defined
   □ Supported Transfer Syntaxes defined

4. Security (if required):
   □ TLS configuration
   □ AE Title authentication
   □ IP address whitelisting

5. Testing:
   □ C-ECHO verification successful
   □ Test storage operations
   □ Test query operations

Understanding these networking fundamentals is essential for building reliable DICOM applications. The next sections will cover the specific DIMSE services in detail.

Quiz: DICOM Networking - Service Classes

Question 1 of 4

What is the role of an SCU in DICOM networking?