Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Dark

Collapse
SHARUR
Community Wiki DLMS/COSEM Tools
Search Sign in
Knowledge Base
Fundamentals 1.1 Architecture & Layers 1.2 Standards & Books Map 1.3 Logical Devices & SAP
Transport & Data Link 2.1 HDLC Type 3 Framing 2.2 TCP Port 4059 Wrapper 2.3 Optical Probe & Mode E 2.4 HDLC Segmentation & CRC
COSEM Data Model 3.1 OBIS Codebook Structure 3.2 Electricity OBIS Registry 3.3 Registers & Negative Scalers 3.4 Profile Generic & Selective Access 3.5 Clock RTC & DST Timing 3.6 Disconnect Control (Relay) 3.7 Schedules & Epoch Anchoring 3.8 A-XDR Tag Directory 3.0 Interface Classes (Legacy)
Security & Protocols 4.1 ACSE Lifecycle (AARQ/AARE) 4.2 Security Suites Matrix 4.3 HLS 5 GMAC Handshake 4.4 General-Glo-Ciphering (0xDB) 4.5 Invocation Counter Sync 4.6 Object Access Control Matrix 4.0 Security Suites (Legacy)
Advanced Transmission 5.1 DataBlock-G vs GBT 5.2 Class 18 OTA Firmware 5.3 Push Setup & Events
Troubleshooting & Recipes 6.1 SDK Integration Guide 6.2 Top 10 Diagnostic Traps 6.0 Standards & SDKs (Legacy)
Fundamentals 4 min read GitHub-Docs Specification Safe Harbor Redacted
Wiki Fundamentals 1.1 Architecture & Layers

1.1 DLMS / COSEM Architecture & Layering Model

Comprehensive architectural breakdown of DLMS/COSEM three-layer communication profiles, protocol boundaries, and media independence.


1. Overview & Protocol Hierarchy

DLMS / COSEM (Device Language Message Specification / Companion Specification for Energy Metering) is the globally adopted open standard suite (IEC 62056) for smart electricity, gas, heat, and water metering.

The architecture strictly follows a streamlined three-layer communication profile that cleanly decouples application semantics from physical transmission media:

LayerPrimary SpecificationCore Responsibility & Primitives
COSEM Application LayerIEC 62056-53 / Blue BookObject modeling (COSEM), xDLMS APDUs (GET, SET, ACTION, Data-Notification), Security Suites, and ASN.1 / A-XDR encoding.
Communication Profile (Transport)IEC 62056-46 (HDLC) / IEC 62056-47 (TCP/IP)Handles link-layer framing, addressing, segmentation, flow control, and channel state management.
Physical & Media LayerIEC 62056-21 / RS-485 / Optical / CellularPhysical transmission over optical probes, twisted-pair RS-485, cellular (NB-IoT/LTE-M/4G), or G3-PLC.

2. Protocol Stack Diagram

TEXT
┌─────────────────────────────────────────────────────────────┐
│                 COSEM Application Layer                     │
│  [COSEM Objects (OBIS)]  [xDLMS Services]  [Security Suite] │
├─────────────────────────────────────────────────────────────┤
│                 LLC Sub-Layer (0xE6 E6 0x00)                │
├──────────────────────────────┬──────────────────────────────┤
│    IEC 62056-46 (HDLC)       │    IEC 62056-47 (TCP/UDP)    │
│  [HDLC Format 3 / S-Bit / CRC]│  [Port 4059 Wrapper (8 Bytes)]│
├──────────────────────────────┼──────────────────────────────┤
│  Optical / RS-485 Serial     │  Cellular / Ethernet / IP    │
└──────────────────────────────┴──────────────────────────────┘

3. Normative Standards References

- **IEC 62056-53**: COSEM Application layer - **DLMS Blue Book Ed. 17**: COSEM Interface Classes and OBIS Object Identification System - **DLMS Green Book 10th Ed**: Architecture and Protocols Specification
Wiki Fundamentals 1.2 Standards & Books Map

1.2 IEC 62056 Standard Suite & Colored Books Map

Reference map correlating the DLMS UA Colored Books with official IEC, ANSI, and EN international standards.


1. The DLMS UA "Colored Books" System

The DLMS User Association publishes the core specifications, commonly categorized by book color:

Book ColorDocument ScopeCore ContentPrimary IEC Equivalent
📘 Blue BookCOSEM Interface Classes & OBIS System70+ Interface Classes, attributes, methods, OBIS 6-group naming rules, and A-XDR data types.IEC 62056-61 / IEC 62056-62
📗 Green BookArchitecture & Communication ProtocolsACSE association state machine, Security Suites 0/1/2, HDLC/TCP profiles, and GBT streaming.IEC 62056-46 / IEC 62056-47 / IEC 62056-53
📙 Yellow BookConformance Testing & CTT ToolTest cases, conformance test tool (CTT) test suites, and interoperability certification criteria.N/A (DLMS UA CTT)
⚪ White BookArchitecture ExtensionsSpecific utility profile guidelines (IDIS, PRIME, G3-PLC, SMETS2).Industry Profiles

2. IEC 62056 Standards Breakdown

- **IEC 62056-21**: Direct local data exchange (Optical probe Mode A/B/C/D/E) - **IEC 62056-46**: Data link layer using HDLC protocol - **IEC 62056-47**: COSEM transport layer for IPv4 / IPv6 networks - **IEC 62056-53**: COSEM application layer - **IEC 62056-61**: Object Identification System (OBIS) - **IEC 62056-62**: COSEM Interface Classes
Wiki Fundamentals 1.3 Logical Devices & SAP

1.3 Client/Server Logical Architecture & SAP Addressing

How physical meters partition into Logical Devices, Server SAPs, and role-based Client SAP access points.


1. Logical Devices & Server SAP

A single physical meter can host multiple Logical Devices (LD), each identified by a unique Server SAP (Service Access Point):

Logical Device TypeStandard Server SAPRole & Typical Function
Management Logical Device (LD 1)0x0001 (1)Mandatory primary management entity hosting Association LN, Security Setup, and Clock.
Electricity Metering Device0x0001 or 0x0002Measurement registers, profile generics, and billing capture logs.
Gas / Water / Heat Sub-Meter0x0003 .. 0x000FMulti-utility M-Bus client channels connected through the main meter.

2. Client SAP Hierarchy & Permissions

Clients connect to the meter using assigned Client SAP addresses representing security roles:

TEXT
Client SAP 0x0010 (16): Public Client     ───► No Encryption, Basic Read (LDN, IC)
Client SAP 0x0001 (1) : Management Client  ───► HLS 5 GMAC, Full Configuration & Relay Trip
Client SAP 0x0002 (2) : Firmware Upgrade   ───► Image Transfer (Class 18)
Client SAP 0x0003 (3) : Utility Reader     ───► Tariff Read & Billing Data Export

3. Addressing Rules in HDLC vs TCP Wrapper

- **TCP Wrapper (`IEC 62056-47`)**: Client SAP and Server SAP are 16-bit integers in the 8-byte wrapper header. - **HDLC (`IEC 62056-46`)**: Client SAP is 1 byte; Server SAP is encoded as 1, 2, or 4-byte HDLC MAC address with bit-shifting (`Address << 1 | 1`).
Wiki Transport & Data Link 2.1 HDLC Type 3 Framing

2.1 IEC 62056-46 HDLC Link Layer & Frame Format Type 3

In-depth dissection of HDLC Frame Format Type 3 structure, MAC addressing, dual CRC-16 checksums, and link state management.


1. HDLC Frame Format Type 3 Structure

A standard DLMS HDLC frame is delimited by opening and closing 0x7E flag bytes:

TEXT
┌──────┬──────────────────────┬──────────┬──────────┬─────────┬────────┬───────────────────┬────────┬──────┐
│ Flag │ Format & Length (2B) │ Dest MAC │ Src MAC  │ Control │  HCS   │ Information Field │  FCS   │ Flag │
│ 0x7E │ Type 3 / S-Bit / Len │ (1-4 B)  │ (1-4 B)  │ (1 B)   │ (2 B)  │ (LLC + xDLMS APDU)│ (2 B)  │ 0x7E │
└──────┴──────────────────────┴──────────┴──────────┴─────────┴────────┴───────────────────┴────────┴──────┘

2. Interactive HDLC Frame Dissection

SNRM (Set Normal Response Mode) Frame:

HEX
7E A0 0A 00 02 00 23 03 93 9A FB 7E
- `7E`: Opening Flag - `A0 0A`: Format Type 3 (`0xA`), Non-segmented (`S=0`), Length = 10 bytes (`0x00A`) - `00 02 00 23`: Destination Upper MAC = 1 (Management), Lower MAC = 17 - `03`: Source MAC = Client SAP 1 (`0x01 << 1 | 1 = 0x03`) - `93`: Control Byte = `SNRM` (Poll bit = 1) - `9A FB`: HCS (Header Check Sequence, CRC-16 CCITT) - `7E`: Closing Flag

3. HDLC Control Commands Table

- **`0x93` / `0x83`**: `SNRM` — Initialize HDLC connection - **`0x73` / `0x63`**: `UA` — Unnumbered Acknowledge (Confirmation) - **`0x53` / `0x43`**: `DISC` — Disconnect link - **`0x10 .. 0xFE`**: `I-Frame` — Information Frame carrying LLC (`E6 E6 00`) and APDU - **`0x11` / `0x01`**: `RR` — Receive Ready flow control ACK
Wiki Transport & Data Link 2.2 TCP Port 4059 Wrapper

2.2 IEC 62056-47 TCP/UDP Port 4059 Wrapper Profile

Protocol specification for the lightweight 8-byte TCP/UDP Wrapper header used over IP networks and cellular IoT.


1. The 8-Byte Wrapper Header

Unlike HDLC, the IP transport profile (IEC 62056-47) eliminates flag bytes, bit stuffing, and CRC checks (relying on TCP checksums) and prefixes all APDUs with an 8-byte Wrapper Header:

TEXT
┌─────────────────┬─────────────────┬─────────────────┬─────────────────┐
│  Protocol Ver   │   Source WPort  │ Destination WPort│   Length (2B)   │
│  0x00 0x01 (2B) │  Client SAP(2B) │  Server SAP(2B) │ APDU Length(2B) │
└─────────────────┴─────────────────┴─────────────────┴─────────────────┘

2. Interactive Frame Example

Wrapper GET Request on Management Client:

HEX
00 01 00 01 00 01 00 0D C0 01 C1 00 01 00 00 01 00 00 FF 02 00
- `00 01`: Protocol Version = 1 - `00 01`: Source WPort = Client SAP 1 (Management Client) - `00 01`: Destination WPort = Server SAP 1 (Management Logical Device) - `00 0D`: Length = 13 bytes following header - `C0 01 C1 ...`: xDLMS `Get-Request-Normal` for Clock (`0.0.1.0.0.255`)

3. TCP Keep-Alive & Long Connections

- Default IANA listening port is **TCP 4059** (and UDP 4059). - For cellular NB-IoT/4G meters, TCP keep-alive packets or application-layer heartbeats are sent at 60s to 300s intervals to prevent carrier NAT timeout teardown.
Wiki Transport & Data Link 2.3 Optical Probe & Mode E

2.3 IEC 62056-21 Optical Probe & Mode E Baud Rate Adaptation

How handheld units and optical probes execute initial sign-on at 300 baud and switch to high-speed HDLC at 9600/19200 baud.


1. Sign-on Sequence & Baud Switching

Under IEC 62056-21 Mode E, optical communication starts at 300 baud (7E1) and transitions to high-speed DLMS HDLC:

TEXT
Handheld Unit (HHU)                                Meter (Server)
      │                                                  │
      │─── /?!<CR><LF> (300 Baud Sign-On) ──────────────►│
      │                                                  │
      │◄── /LOG5\2ZMD410...<CR><LF> (Identification) ────│
      │                                                  │
      │─── <ACK>050<CR><LF> (Mode E Handshake) ─────────►│
      │                                                  │
   [Switch to 9600 / 19200 Baud, 8N1 HDLC Framing]       │
      │                                                  │
      │─── 7E A0 0A 00 02 00 23 03 93 9A FB 7E (SNRM) ──►│
      │◄── 7E A0 1F 03 00 02 00 23 73 ... 7E (UA) ──────│

2. Mode E Protocol Parameter Breakdown

- `/LOG5\2`: `LOG` = Manufacturer ID, `5` = 9600 Baud rate character, `2` = Mode E (HDLC switching). - `050`: `0` = Normal protocol, `5` = 9600 Baud acknowledged, `0` = Data mode.
Wiki Transport & Data Link 2.4 HDLC Segmentation & CRC

2.4 HDLC Frame Segmentation & Two-Tier CRC-16 Checksum State Machine

The mechanics of S-bit link-layer fragmentation, LLC sublayer positioning, CRC-16 CCITT validation, and full buffer reassembly before deciphering.


1. Segmentation Bit (S-Bit) & LLC Positioning

Per IEC 62056-46 Section 6.4.4.4.3: - When an APDU exceeds the maximum frame length, HDLC splits it across multiple frames. - Format Type 3 Byte 2 Bit 11 is the S-bit (0xA8 for segmented, 0xA0 for final/unsegmented). - LLC Sublayer (0xE6 0xE6 0x00) is included ONLY in Segment 1. Continuation segments contain raw payload bytes immediately following the Control field!

TEXT
Segment 1 (S=1): [7E] [A8 84] [Dest] [Src] [Ctrl] [HCS] [E6 E6 00] [Ciphertext Part 1] [FCS] [7E]
Segment 2 (S=1): [7E] [A8 80] [Dest] [Src] [Ctrl] [HCS]          [Ciphertext Part 2] [FCS] [7E]
Segment 3 (S=0): [7E] [A0 42] [Dest] [Src] [Ctrl] [HCS]          [Ciphertext Part 3 + Tag] [FCS] [7E]

2. Golden Rule of DLMS Decryption

**Do NOT decrypt individual HDLC segments.** 1. Verify CRC-16 FCS for each segment independently; 2. Concatenate raw payload bytes into a single contiguous buffer; 3. Feed the complete buffer into AES-GCM-128 for authentication and decryption.
Wiki COSEM Data Model 3.1 OBIS Codebook Structure

3.1 OBIS Identification System & 6-Group (A-F) Structure

The universal 6-group (A.B.C.D.E.F) hierarchical naming convention defined in the DLMS Blue Book and IEC 62056-61.


1. OBIS Group Architecture

Every physical or logical quantity in DLMS is addressed by a 6-tuple: A.B.C.D.E.F:

GroupMeaningRange & Standard Value Assignments
AMedium0: Abstract / General, 1: Electricity, 4: Heat, 7: Gas, 8: Water.
BChannel0: No channel, 1..64: Multi-channel measurement inputs.
CPhysical Quantity1: Active Power (+), 3: Reactive (+), 11/12: Phase L1 Volt/Current, 96: Service/Tamper.
DMeasurement Type8: Time-integral (Energy), 7: Instantaneous value, 4: Current average.
ETariff / Rate0: Total, 1..8: Tariff Rates T1 to T8.
FBilling Period255 (0xFF): Current value, 0..99: Historical billing capture indices.

2. Common OBIS Examples

- `1.0.1.8.0.255`: Active Energy Import Total (Current) - `1.0.31.7.0.255`: Instantaneous Current Phase L1 - `1.0.32.7.0.255`: Instantaneous Voltage Phase L1 - `0.0.1.0.0.255`: Real-Time Clock (Class 8)
Wiki COSEM Data Model 3.2 Electricity OBIS Registry

3.2 Electricity OBIS Code Registry & Multi-Tariff Models

Authoritative registry of standard electricity measurement OBIS codes across single-phase and polyphase smart meters.


1. Active & Reactive Energy Registry

OBIS CodeInterface ClassAttributeDescription & Typical Units
1.0.1.8.0.255Class 3 / 42Total Active Import Energy ($+A$) [Wh]
1.0.1.8.1.255Class 3 / 42Tariff 1 Active Import Energy ($+A$ T1) [Wh]
1.0.1.8.2.255Class 3 / 42Tariff 2 Active Import Energy ($+A$ T2) [Wh]
1.0.2.8.0.255Class 3 / 42Total Active Export Energy ($-A$) [Wh]
1.0.3.8.0.255Class 3 / 42Total Reactive Import Energy ($+R$) [varh]

2. Instantaneous Grid Quality Telemetry

OBIS CodeInterface ClassAttributeDescription & Units
1.0.32.7.0.255Class 32Phase L1 RMS Voltage [0.1 V] (Scaler = -1)
1.0.52.7.0.255Class 32Phase L2 RMS Voltage [0.1 V] (Scaler = -1)
1.0.72.7.0.255Class 32Phase L3 RMS Voltage [0.1 V] (Scaler = -1)
1.0.31.7.0.255Class 32Phase L1 RMS Current [0.001 A] (Scaler = -3)
1.0.14.7.0.255Class 32Grid Frequency [0.01 Hz] (Scaler = -2)
Wiki COSEM Data Model 3.3 Registers & Negative Scalers

3.3 Class 3/4 Registers & Signed 8-Bit Negative Scaler Parsing

How to decode Class 3/4 ScalerUnit structures, parse signed 8-bit negative exponents (-3), and prevent floating point precision loss.


1. Register Interface Class (Class 3 & 4)

Per DLMS Blue Book Section 4.3.3, Class 3 contains: - Attribute 2 (value): Measurement quantity (integer/long/double-long) - Attribute 3 (scaler_unit): Structure containing: - scaler: Integer8 (Tag 0x0F) — SIGNED 8-bit integer! - unit: Enum (Tag 0x16)

2. The Negative Scaler Decoding Trap

$$\text{Physical Value} = \text{Raw Value} \times 10^{\text}$$ - If raw value = `5230` and scaler byte = `0xFD` ($-3$ in signed int8): $$\text = 5230 \times 10^ = 5.230\text$$ - **Common Bug**: If decoded as `uint8` (`+253`), value explodes to $5.23 \times 10^$!

3. High Cumulative Energy & Float32 Rounding Trap

Cumulative energy exceeding $16{,}777{,}216\text$ will lose Wh increments under IEEE 754 `float32`. Always use `Decimal` or 64-bit integer arithmetic.
Wiki COSEM Data Model 3.4 Profile Generic & Selective Access

3.4 Class 7 Profile Generic Load Buffers & Selective Access

Architecture of load profile circular buffers, capture objects definition, and time-range vs entry-index selective filtering.


1. Profile Generic (Class 7) Architecture

Class 7 manages periodic interval capture (e.g. 15-minute load profiles, daily billing profiles): - Attribute 2 (buffer): Two-dimensional table of captured records. - Attribute 3 (capture_objects): Array of column descriptors (Class ID, OBIS, Attribute ID). - Attribute 4 (capture_period): Interval in seconds (e.g. 900 for 15 min).

2. Selective Access Selector 1 (By Date Range)

To query records between two timestamps without fetching entire megabyte logs:
ASN1
SelectiveAccessDescriptor ::= Structure {
  access_selector: 1 (RangeDescriptor),
  access_parameters: Structure {
    restricting_object: Structure { class_id: 8, obis: 0.0.1.0.0.255, attribute_id: 2 },
    from_value: Date_Time ("2026-08-01 00:00:00"),
    to_value:   Date_Time ("2026-08-01 23:59:59"),
    selected_values: Array [] // Empty array = all columns
  }
}
Wiki COSEM Data Model 3.5 Clock RTC & DST Timing

3.5 Class 8 Clock RTC 12-Byte Octet-String & DST Drift Mitigation

The precise 12-byte date_time octet-string layout, timezone deviation offsets, daylight saving status masks, and clock synchronization.


1. The 12-Byte Date_Time Structure

Per DLMS Blue Book Section 4.1.6.1, the standard timestamp is a 12-byte Octet-String:

ByteFieldDescription & Valid Range
0 - 1Year16-bit Big-Endian (e.g. 0x07EA = 2026, 0xFFFF = wildcard)
2Month1..12 (0xFF = wildcard, 0xFD = daylight savings end)
3Day of Month1..31 (0xFD..0xFF = special/wildcard)
4Day of Week1 (Monday) to 7 (Sunday), 0xFF = not specified
5Hour0..23 (0xFF = wildcard)
6Minute0..59 (0xFF = wildcard)
7Second0..59 (0xFF = wildcard)
8Hundredths0..99 (0xFF = not specified)
9 - 10DeviationSigned 16-bit offset from UTC in minutes (e.g. +480 for UTC+8)
11Clock StatusBitmask: Bit 0 (invalid), Bit 1 (doubtful), Bit 7 (daylight savings active)
Wiki COSEM Data Model 3.6 Disconnect Control (Relay)

3.6 Class 70 Disconnect Control & Remote Tripping Safety

Operating internal meter load disconnect switches safely via Class 70 methods, control states, and lockout protections.


1. Disconnect Control (Class 70) Attributes

- **Attribute 2 (`output_state`)**: `Boolean` (`true` = connected, `false` = disconnected). - **Attribute 3 (`control_state`)**: `Enum` (`0`: Disconnected, `1`: Connected, `2`: Ready for Reconnection). - **Attribute 4 (`control_mode`)**: Modes 1 to 6 controlling manual push-button vs remote reconnect conditions.

2. Remote Disconnect / Reconnect Methods

- **Method 1 (`remote_disconnect`)**: Opens contactor, trips power. - **Method 2 (`remote_reconnect`)**: Closes contactor or transitions to `Ready for Reconnection` mode.
CAUTION

In Security Suite 1, Class 70 methods must ALWAYS be transmitted inside `General-Glo-Ciphering` (`0xDB`) with authenticated and encrypted security!

Wiki COSEM Data Model 3.7 Schedules & Epoch Anchoring

3.7 Class 20/22 Schedules & Safe Distant Epoch Anchoring

Why using 0xFF wildcards triggers continuous 1Hz execution loops, why 01 00 empty arrays fail on legacy firmware, and why 2099/2100 is the universal standard.


1. Schedule Execution Time Traps

- **Trap 1 (0xFF Wildcards)**: Writing `FF FF FF FF` across time bytes matches every second, causing an infinite 1Hz execution storm. - **Trap 2 (Past Times / 0000:00:00)**: RTOS delta schedulers evaluate past timestamps as expired alarms and fire immediately upon `SET`. - **Trap 3 (Year 9999 Overflow)**: Exceeds 32-bit signed Unix epoch ($2^-1$) and wraps into year 1911. - **Trap 4 (Empty Array `01 00` Failure)**: Rejected by ~15% of meter firmware enforcing static `min_entries >= 1` table constraints.

2. The Universal Golden Standard (Year 2099/2100)

Setting a confirmed distant future timestamp:
HEX
09 0C 08 33 0C 1F FF 17 3B 3B 00 80 00 00
(`2099-12-31-FF 23:59:59`) passes 100% of schema validators without side effects.
Wiki COSEM Data Model 3.8 A-XDR Tag Directory

3.8 A-XDR BER Tag Encoding Directory & Data Structure Trees

Complete catalog of A-XDR compact primitive type tags, ASN.1 structures, length octet encodings, and nested data parsing.


1. Standard A-XDR Type Tags Directory

Tag (Hex)A-XDR Type NameEncoding Format & Length Rules
0x00null-data0 bytes payload
0x01arrayLength byte $N$ followed by $N$ elements
0x02structureLength byte $N$ followed by $N$ distinct typed elements
0x03boolean1 byte (0x00 = false, 0x01 = true)
0x04bit-stringLength in bits followed by packed byte array
0x05double-long4 bytes signed integer
0x06double-long-unsigned4 bytes unsigned integer
0x09octet-stringLength byte $L$ followed by $L$ raw bytes
0x0Cutf8-stringLength byte $L$ followed by $L$ UTF-8 characters
0x0Finteger81 byte signed integer ($-128 .. +127$)
0x11unsigned81 byte unsigned integer ($0 .. 255$)
0x12long-unsigned2 bytes unsigned integer (16-bit)
0x16enum1 byte unsigned enumeration
Wiki Security & Protocols 4.1 ACSE Lifecycle (AARQ/AARE)

4.1 ACSE Association Lifecycle (AARQ 0x60 / AARE 0x61 / RLRQ / ABRT)

State machine and ASN.1 handshake exchange for Association Request (AARQ), Response (AARE), Release (RLRQ), and Abort (ABRT).


1. ACSE Association Exchange

TEXT
Client (HES)                                     Meter (Server)
    │                                                   │
    │─── AARQ (0x60) [App Context, System Title, CtoS] ─►│
    │                                                   │
    │◄── AARE (0x61) [Result: 00, System Title, StoC] ──│
    │                                                   │
    │─── Action-Request (Method 1: CtoS GMAC Tag) ──────►│
    │                                                   │
    │◄── Action-Response (Method 1: Server Proof Tag) ──│
    │                                                   │
    │========= Associated (Authorized Channel) =========│
    │                                                   │
    │─── RLRQ (0x62) [Release Request] ────────────────►│
    │◄── RLRE (0x63) [Release Response] ────────────────│

2. AARQ APDU Dissection

- `0x60`: `AARQ` tag - `0xA1`: Application Context Name (`LN_with_ciphering` or `LN_no_ciphering`) - `0xA6`: Calling AP Title (Client System Title, 8 bytes) - `0xAC`: Calling Authentication Value (CtoS Challenge) - `0xBE`: User Information field containing proposed xDLMS `InitiateRequest`
Wiki Security & Protocols 4.2 Security Suites Matrix

4.2 Security Suites 0, 1 & 2 Cryptographic Matrix

Comparative cryptographic profile across DLMS Security Suite 0 (legacy), Suite 1 (AES-128 + ECC P-256), and Suite 2 (AES-256 + P-384).


1. Cryptographic Algorithms Comparison

Security ParameterSecurity Suite 0 (Legacy)Security Suite 1 (Current Standard)Security Suite 2 (High Security)
Symmetric CipherAES-GCM-128AES-GCM-128AES-GCM-256
Key AgreementPre-shared Static KeysECDH over NIST P-256 (Ephemeral)ECDH over NIST P-384
Digital SignatureNoneECDSA with SHA-256 (NIST P-256)ECDSA with SHA-384 (NIST P-384)
GMAC Tag Length12 Bytes12 Bytes12 Bytes
Invocation Counter4 Bytes (Mandatory)4 Bytes (Mandatory)4 Bytes (Mandatory)
Wiki Security & Protocols 4.3 HLS 5 GMAC Handshake

4.3 HLS 5 (GMAC) Challenge-Response Mutual Authentication & Table 43 Vectors

Bidirectional challenge calculation, Client/Server System Title orientation, and Green Book Table 43 official verification vectors.


1. HLS 5 Challenge-Response Formula

$$\text{CtoS Tag} = \text_{\text}(\text \parallel IC_{\text}, \text_{\text}, \text)$$ $$\text{StoC Tag (Server Proof)} = \text_{\text}(\text \parallel IC_{\text}, \text_{\text}, \text)$$

2. Official Green Book Table 43 Standard Vector

- **Client System Title**: `4D4D4D0000000001` - **Authentication Key (GAK)**: `D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF` - **StoC Challenge**: `503677524A323146` - **Client IC**: `1` - **Expected HLS CtoS Output**:
HEX
10 00 00 00 01 1A 52 FE 7D D3 E7 27 48 97 3C 1E 28
Wiki Security & Protocols 4.4 General-Glo-Ciphering (0xDB)

4.4 General-Glo-Ciphering (0xDB) & Security Control Byte Bitmasks

Deconstructing the 0xDB encrypted APDU envelope, Security Control bitmasks, IV assembly, and AAD formulation.


1. Structure of General-Glo-Ciphering (0xDB)

TEXT
┌──────┬────────┬──────────────┬────────┬────────────────┬──────────────────────────┬──────────┐
│ Tag  │ Length │ System Title │ SC (1B)│ Invocation Cnt │ Ciphertext Stream (AES)  │ GMAC Tag │
│ 0xDB │  0x08  │   (8 Bytes)  │  0x30  │   (4 Bytes)    │ (Encrypted xDLMS APDU)   │ (12 B)   │
└──────┴────────┴──────────────┴────────┴────────────────┴──────────────────────────┴──────────┘

2. Security Control Byte (SC) Bitmask

- **Bits 0-1**: Security Suite ID (`00` = Suite 0, `01` = Suite 1, `10` = Suite 2) - **Bit 4**: **Authenticated** (`1` = Authenticated via GMAC) - **Bit 5**: **Encrypted** (`1` = Encrypted via AES-CTR) - **Bits 6-7**: Key type (`00` = Global Unicast Key GUEK, `01` = Dedicated Key, `10` = Broadcast Key)

Common SC values: - 0x10: Global Key, Authenticated Only - 0x30: Global Key, Authenticated & Encrypted (Standard Production Mode)

Wiki Security & Protocols 4.5 Invocation Counter Sync

4.5 Invocation Counter ($IC$) Non-Volatile Persistence & Cold-Start Sync

How non-volatile storage in smart meters enforces anti-replay policies across TCP teardowns and how HES pre-reads IC via Public Client.


1. The Monotonic IC Invariant

- The meter security engine drops any frame where $IC_{\text} \le IC_{\text}$. - Resetting $IC$ to `1` upon HES worker restart locks out communication permanently.

2. Cold-Start Synchronization Procedure

1. Connect via **Public Client (SAP 16)** (Plain, no ciphering required); 2. Read **Class 64 (`Security Setup`, `0.0.43.1.0.255`) Attribute 4** (`global_invocation_counter`); 3. Synchronize HES counter: $$\text IC = \text IC + 50$$ 4. Reconnect via Management Client (SAP 1) with synchronized counter.
Wiki Security & Protocols 4.6 Object Access Control Matrix

4.6 Association LN Access Control Matrix & Object Access Modes

Why authenticated HLS 5 associations fail with scope-of-access-violated when reading Class 70 or Class 8 without PDU-level encryption.


1. Object Access Modes in Association LN

Per DLMS Blue Book Section 4.5.3, Attribute 2 of 0.0.40.0.0.255 defines per-object permissions: - 1: read_only (Plaintext allowed) - 3: read_and_write - 4: authenticated_read - 5: authenticated_and_encrypted_read

If Clock (Class 8) or Relay (Class 70) is configured with Mode 5, sending a plain Get-Request results in scope-of-access-violated (0xC4 0x01 C1 01 01). The request must be wrapped inside 0xDB ciphering.

Wiki Advanced Transmission 5.1 DataBlock-G vs GBT

5.1 xDLMS DataBlock-G vs GBT (General Block Transfer) Streaming

Comparing traditional stop-and-wait datablocks with General Block Transfer (GBT) streaming windows, and resolving AARQ Bit 19 negotiation deadlocks.


1. DataBlock-G vs GBT

FeatureTraditional DataBlock (0xC4 0x02)General Block Transfer (GBT 0xE0)
Transmission Mode1-by-1 stop-and-waitStreaming sliding window (Window size 1 to 64)
Round-Trip DelayHigh latency over cellular NB-IoT75% faster bulk transfer throughput
Conformance BitStandard ConformanceBit 19 (general-block-transfer)
Framing TagxDLMS Service Tag0xE0 GBT Control Header inside 0xDB

2. Conformance Bit 19 Rule

If HES does not support GBT, ensure Bit 19 is cleared in `AARQ` (`0x007E1F`).
Wiki Advanced Transmission 5.2 Class 18 OTA Firmware

5.2 Class 18 Image Transfer Firmware OTA Upgrade & Signature Verification

Complete OTA firmware upgrade lifecycle: initiation, zero-indexed block transfer, bitstring tracking, ECDSA signature formats, and activation.


1. The 4-Step Image Transfer Lifecycle

Per DLMS Blue Book Section 4.3.8 (0.0.44.0.0.255): 1. Method 1 (image_initiate): Pass image identifier (e.g. "V3.2.0") and image size in bytes; 2. Method 2 (image_block_transfer): Send blocks sequentially starting at block_number = 0; 3. Method 3 (image_verify): Submit digital signature (ASN.1 DER encoded ECDSA P-256); 4. Method 4 (image_activate): Execute firmware flash and reboot.

Wiki Advanced Transmission 5.3 Push Setup & Events

5.3 Class 40 (Push Setup) Unsolicited Event Notification & Backoff

Configuring unsolicited alarm pushes (power outage, tamper detection) over TCP/UDP and managing randomized backoff retry intervals.


1. Push Setup (Class 40) Configuration

- **Attribute 2 (`push_object_list`)**: Array of captured OBIS attributes sent in push; - **Attribute 3 (`send_destination_and_method`)**: Destination IP, port, and transport protocol (TCP/UDP); - **Attribute 5 (`randomisation_start_interval`)**: Random delay to prevent simultaneous grid reconnection storms.
Wiki Troubleshooting & Recipes 6.1 SDK Integration Guide

6.1 Open-Source SDK Integration Guide (Gurux.DLMS / Python / C)

Step-by-step developer guide for connecting to smart meters using Gurux.DLMS in Python, ANSI C, and Java.


1. Python Gurux.DLMS Quickstart

PYTHON
from gurux_dlms.secure import GXDLMSSecureClient
from gurux_dlms.enums import Authentication, Security, InterfaceType
from gurux_dlms.objects import GXDLMSClock

client = GXDLMSSecureClient(True, 1, 1, Authentication.HIGH_GMAC, None, InterfaceType.WRAPPER) client.ciphering.systemTitle = bytes.fromhex("4D4D4D0000000001") client.ciphering.authenticationKey = bytes.fromhex("D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF") client.ciphering.blockCipherKey = bytes.fromhex("000102030405060708090A0B0C0D0E0F") client.ciphering.security = Security.AUTHENTICATION_ENCRYPTION

# Ready to generate AARQ and exchange messages

Wiki Troubleshooting & Recipes 6.2 Top 10 Diagnostic Traps

6.2 Top 10 DLMS Engineering Traps & Diagnostic Fault Tree

Comprehensive diagnostic fault tree resolving the 10 most common DLMS engineering failures in lab and field deployments.


1. Top 10 Diagnostic Fault Matrix

#Observed SymptomPrimary Root CauseStandard Remediation
1invalid-password / challenge-mismatchIV System Title inverted during Server ProofUse Server System Title for StoC verification (Green Book Table 43).
2scope-of-access-violated (0xC4 0x01 C1 01 01)Plaintext read on Class 70/8Wrap request in 0xDB General-Glo-Ciphering.
3Meter drops fresh connection after restartIC reset to 1 (Replay protection)Pre-read Class 64 Attribute 4 via Public Client (SAP 16).
4Current value reports $10^$ AScaler byte 0xFD decoded as unsignedUnpack 0x0F as signed 8-bit integer (struct.unpack('b')).
5Block Transfer out-of-sequence error15-min circular buffer shift without snapshotEnforce Selective Access by Date Range (Blue Book 4.3.7.2).
6OTA image_verify failsBlock transfer started at 1 instead of 0Ensure block numbers start at 0 (Blue Book 4.3.8).
7OTA signature rejectedRaw 64B vs 71B ASN.1 DER ECDSA formatWrap ECDSA P-256 in ASN.1 DER 0x30 0x45 0x02 0x21 ....
8Buffer read hangs after AARQConformance Bit 19 GBT mismatchClear Bit 19 in AARQ or implement GBT streaming.
9Schedule continuous 1Hz firingExecution time set with 0xFF wildcardsUse confirmed safe distant epoch (2099-12-31-FF 23:59:59).
10Cumulative energy increments lostFloat32 24-bit mantissa truncation
Use `Decimal` or 64-bit integer arithmetic.
Wiki COSEM Data Model 3.0 Interface Classes (Legacy)

3.0 COSEM Interface Classes & Object Architecture

Fundamental object-oriented architecture of COSEM Interface Classes defined in IEC 62056-62 and Blue Book.


1. COSEM Interface Classes Hierarchy

COSEM structures meter data into discrete, strongly-typed Interface Classes: - **Class 1 (Data)**: Simple variables (Logical Device Name `0.0.42.0.0.255`) - **Class 3 (Register)**: Measurement scalars with `scaler_unit` (`1.0.1.8.0.255`) - **Class 4 (Extended Register)**: Register with capture timestamp and status - **Class 7 (Profile Generic)**: Circular historical capture buffers - **Class 8 (Clock)**: 12-byte real-time clock and calendar - **Class 15 (Association LN)**: Application association and access rights table - **Class 70 (Disconnect Control)**: Remote relay tripping and reconnection
Wiki Security & Protocols 4.0 Security Suites (Legacy)

4.0 AARQ Handshake & Security Suites 0/1/2 Overview

Application Association Request (AARQ) parameters, High Level Security (HLS 5 GMAC), and ciphering suites.


1. Association & Security Parameters

- **Application Context**: `LN_with_ciphering` (`2.16.756.5.8.1.3`) - **Calling AP Title**: 8-byte Client System Title (e.g. `4D4D4D0000000001`) - **Security Control (`0x30`)**: Authenticated and Encrypted via AES-GCM-128.
Wiki Troubleshooting & Recipes 6.0 Standards & SDKs (Legacy)

6.0 Official Standards, CTT & Open-Source SDKs

Official standards portals, DLMS UA testing tools, and open-source protocol libraries.


1. Official Standards & Conformance Links

- Official Portal: DLMS User Association Official Portal - IEC Webstore: IEC 62056 Standards Suite - Gurux C Stack: Gurux.DLMS.c GitHub Repository - Gurux Objects Directory: Gurux DLMS Objects Reference - OpenMUC Java: OpenMUC jDLMS Library
Raw Markdown Source
Pure Client-Side AST Token Stream (JSON)

Related Engineering Cases & Deep Debates

Loading related community cases...
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups