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:
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.
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.
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
| Status | Meaning |
|---|---|
| 0x0000 | Success |
| 0x0122 | SOP Class not supported |
| 0x0210 | Duplicate invocation |
| 0x0211 | Unrecognized operation |
| 0x0212 | Mistyped 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.