Network concepts
What happens when two DICOM programs talk over TCP, and which types of the
network package stand for each part. Read this before
the SCU guide or the SCP guide if
associations, presentation contexts and DIMSE statuses are new to you.
Overview
Two Application Entities (AEs) open an association, agree on what they will exchange, send DIMSE messages over it, and release it. The side that asks for the association is the requestor; in the services covered here it is usually the Service Class User (SCU), and the side that accepts is the Service Class Provider (SCP).
| Concept | In the standard | In network |
|---|---|---|
| Client | SCU | SCU, configured by SCUConfig |
| Server | SCP | SCP or Server, configured by SCPConfig |
| What the server does with a request | Service class behavior | Handler |
| The negotiated session | Association (PS3.8) | Association, held by the SCU or SCP |
| A proposed context | Presentation context item | PresentationContextItem |
| A context as answered | Presentation context result | PresentationContext, NegotiatedContext |
| Optional negotiation items | Extended negotiation (PS3.7 D.3.3) | ExtendedNegotiation |
| Low-level timers and sizes | ARTIM, Maximum Length | NetworkConfig |
| What happened, as it happened | (not in the standard) | EventManager and the -events log |
AE titles
An AE title names a DICOM node: 1 to 16 characters of the default repertoire,
no backslash, not all spaces (PS3.5 6.2). Each association carries two: the
calling AE title (who asks, SCUConfig.CallingAE, -aet on the command
line) and the called AE title (whom it asks for, SCUConfig.CalledAE,
-aec).
- An SCP answers only to its own title. A request whose called AE title
is not
SCPConfig.AETitleis refused, called-AE-title-not-recognized, unlessSCPConfig.AcceptAnyCalledAEhands that decision toSCPConfig.Admit. Each server command answers to its own name (ECHOSCP,STORESCP,QRSCP,WLMSCP) unless-aetsets another. - Leading and trailing spaces are not significant. They are removed from
both titles before any comparison. Case is kept:
prisma1is notPRISMA1. - A title is a name, not a proof of identity. Anyone who reaches the port can send any calling AE title. See TLS and security.
The client commands call ANY-SCP unless -aec says otherwise, so against a
go-dicom server -aec is needed:
$ go-dicom echoscu 127.0.0.1:41001
Requesting Association with 127.0.0.1:41001 (AE: ANY-SCP)
Error: association failed: association error [ASSOCIATION_REJECTED]: association rejected: result=1, source=1, reason=7
$ go-dicom echoscu -aec ECHOSCP 127.0.0.1:41001
Requesting Association with 127.0.0.1:41001 (AE: ECHOSCP)
Association accepted
Sending C-ECHO...
C-ECHO response: Success (0x0000)
Releasing AssociationReason 7 is called-AE-title-not-recognized (PS3.8 Table 9-21). The
AssociationError
of a refused association carries Result, Source and Reason as numbers.
Presentation contexts
Every message travels on a presentation context: an ID (an odd number from 1 to 255), an abstract syntax and a transfer syntax.
- The abstract syntax is a SOP class: what kind of object or service the message is about, such as CT Image Storage or Study Root Query/Retrieve FIND.
- The transfer syntax is how the data set is encoded: Implicit or Explicit VR, little or big endian, deflated, or with compressed pixel data.
The requestor proposes one or more transfer syntaxes for each abstract syntax. The acceptor answers each context on its own: accepted, with exactly one transfer syntax, or refused, with a reason.
What a go-dicom SCP does with each proposed context:
- It takes the requestor's order. The accepted transfer syntax is the first one the requestor listed that the SCP supports.
- It accepts what
SCPConfig.AbstractSyntaxesandTransferSyntaxeslist. Nil keeps the defaults; a non-nil list is used exactly as given, so an empty one accepts nothing. See Building an SCP. - A refused context does not refuse the association. An association can
be established with nothing usable on it; the first operation then fails.
An SCU explains why with
Association.ExplainNoContextFor, which names the syntaxes it tried. - At most 128 contexts fit in one association. Helpers such as
GetContextsandStoreStreamContextsstop at that bound.
The four uncompressed syntaxes are the default on both sides
(DefaultTransferSyntaxes):
Implicit VR Little Endian, Explicit VR Little Endian, Deflated Explicit VR
Little Endian and Explicit VR Big Endian.
AllTransferSyntaxes
adds the 37 compressed ones. The
conformance statement
lists them.
Roles and extended negotiation
Beyond contexts, an A-ASSOCIATE-RQ may carry optional items, set in
SCUConfig.ExtendedNegotiation:
| Item | Field | What it is for |
|---|---|---|
| Asynchronous operations window | AsyncOperations | How many operations may be outstanding at once. Absent means one. |
| SCP/SCU role selection | RoleSelections | Which side may act as SCP for a SOP class. A C‑GET requestor proposes the SCP role for the storage classes it wants back. DefaultGetRoleSelections builds them. |
| User identity | UserIdentity | A user name and password, Kerberos ticket, SAML assertion or JWT. The SCP passes it to Admit unchecked. |
| SOP Class Extended Negotiation | SOPClassExtended | Service behaviors for one class, such as relational queries for C‑FIND. The agreed answer is Association.AgreedSOPClassExtended. |
An SCP answers SOP Class Extended Negotiation through
SCPConfig.AnswerSOPClassExtended, and lowers the window to
SCPConfig.MaxOperationsPerformed. Details are in
CONFORMANCE.md §3.3.
DIMSE messages and statuses
A DIMSE message is a command set, and for most commands a data set after it.
Requests carry a message ID; each response carries the ID of the request
it answers (Message ID Being Responded To). An SCU numbers its requests
itself, from 1; SCU.PeekNextMessageID
and the OnStart callbacks of FindOptions and RetrieveOptions tell a
caller the ID it needs to cancel an operation.
Every response carries a 16-bit status. The library sorts them with
CategorizeStatus
and the IsSuccess, IsWarning, IsFailure, IsPending and IsCancel
functions; FormatStatus prints one as 0xA801 (Failure).
| Category | Codes | Meaning |
|---|---|---|
| Success | 0000 | Done. |
| Pending | FF00, FF01 | A C‑FIND match, or a C‑MOVE/C‑GET progress report; more responses follow. FF01: a match where some optional keys were not supported. |
| Cancel | FE00 | The operation stopped because the requestor sent C‑CANCEL. |
| Warning | 0001, Bxxx | Done, with a caveat: B000 coercion of data elements (C‑STORE), or some sub-operations failed (C‑MOVE, C‑GET). |
| Failure | everything else | A700 out of resources, A801 move destination unknown, A900 identifier does not match SOP class, Cxxx unable to process, 0110 processing failure, 0122 SOP class not supported, and others. |
How the result reaches a Go caller depends on the call:
- C-ECHO, C-STORE (
Store),Find,Move,Getreturn an error for a status they do not accept, a*DIMSEErrorwhoseStatusfield is the code. StoreStream,FindEach,MoveWithSOPClass,GetWithSOPClassreturn the peer's final status in a result, and an error only when no status was obtained.- The N-services (
NCreate,NSet,NAction,CreateMPPS, ...) return the response with itsStatusandDetail, and an error only for a failed exchange. - A handler on the SCP side returns a status, or, for C-FIND, C-MOVE and
C-GET, an error; a
*StatusErrorchooses which failure is sent.
The SCU guide has the details per call.
Timeouts and PDU sizes
Messages are cut into PDUs (protocol data units). The settings are in
NetworkConfig, the Network field of both configs:
| Setting | Default | What it bounds |
|---|---|---|
NetworkTimeout | 30 s | Opening the TCP connection. |
ARTIMTimeout | 30 s | Association setup and release: the SCP waiting for the A‑ASSOCIATE-RQ, the SCU for the -AC or the A‑RELEASE-RP. |
DIMSETimeout | 60 s | Each PDU after the association is up. An SCP aborts an association idle for longer. |
WriteTimeout | none | Each PDU written, against a peer that stops reading. |
MaxPDUSize | 16384 | The Maximum Length this side advertises: the largest P‑DATA‑TF the peer may send it. |
Zero keeps the default; a negative ARTIMTimeout or DIMSETimeout is no
limit. A PDU longer than this side advertised is aborted, and no PDU may pass
MaxPDULengthLimit
(128 MiB). The command-line clients set NetworkTimeout from -timeout.
Watching an association
Every network command takes -events <file> (or -events - for standard
output) and writes one JSON object per line: every PDU with its bytes, the
negotiated contexts, and every DIMSE message. The format is
a documented contract. Reduced with jq, a C-ECHO looks like
this:
$ go-dicom echoscu -aec ECHOSCP -events echo.jsonl 127.0.0.1:41001 > /dev/null
$ jq -c 'select(.event | test("PDU") | not) | {event, dimse: .dimse.command, status: .dimse.status}' echo.jsonl
{"event":"EVT_CONN_OPEN","dimse":null,"status":null}
{"event":"EVT_REQUESTED","dimse":null,"status":null}
{"event":"EVT_ACCEPTED","dimse":null,"status":null}
{"event":"EVT_ESTABLISHED","dimse":null,"status":null}
{"event":"EVT_DIMSE_SENT","dimse":"C-ECHO-RQ","status":null}
{"event":"EVT_DIMSE_RECV","dimse":"C-ECHO-RSP","status":0}
{"event":"EVT_RELEASED","dimse":null,"status":null}
{"event":"EVT_CONN_CLOSE","dimse":null,"status":null}The EVT_ACCEPTED line holds each context as proposed and as answered
(presentationContexts), which is where a refused transfer syntax shows.
In Go, set SCUConfig.Events or SCPConfig.Events to an
EventManager
and register handlers with On(EventType, ...) or OnAny. Each
Event
carries the association ID, both AE titles and addresses, the PDU, the
command (Command), and, on an abort this side sent, LocalAbort with the
cause.
LoggingEventHandlers
writes them to a log.
Limits and gotchas
- Plain DICOM over TCP is neither encrypted nor authenticated. See TLS and security.
- An association can succeed with no usable context. Check the
EVT_ACCEPTEDline, or the error of the first operation, which says which syntaxes were tried. - Compressed transfer syntaxes are not proposed or accepted by default. CONFORMANCE.md §3.1 says why, and which commands accept them anyway.
- A window above one is negotiated, not assumed. Without an agreed
asynchronous operations window an
SCUruns one operation at a time, and an SCP performs them in order.
See also
Configuration and errors
Where go-dicom logs and how to change it, what the config package's settings do, how errors are shaped across the library, and the limits to set before reading input you do not trust. It is for anyone putting go-dicom into a service or a tool that others feed files to.
Writing an SCU
Next Page