EXI: how V2G messages are encoded

Why V2G messages travel as a few dozen bytes of packed bits rather than XML text, why a decoder needs the exact schema, which schemas exist, and what a decode failure in a capture usually means.

From XML to bits

Every V2G message is defined as an XML document by an XML schema (XSD) that comes with the standard. XML text would be far too large and too slow to parse for a charging controller, so the documents are sent in Efficient XML Interchange (EXI), a W3C binary encoding of the same information. A typical CurrentDemandReq is a few dozen bytes.

V2G uses EXI in its schema informed mode. Both sides compile the schema into grammars: state machines that say, at each point of the document, which elements may come next. The encoder then writes only the choice it made, as an event code of a few bits, instead of the element name. Values are packed just as tightly:

WhatHow it is written
An element that must come nextNothing at all, when the grammar allows only one choice
A choice between elements, or an optional element present or notAn event code of as many bits as the number of choices needs
An enumeration value, for example a ResponseCodeThe index of the value in the list of the schema
An integer with a small rangeJust enough bits for the range: the Multiplier of a PhysicalValue, -3 to 3, takes 3 bits
Other integersA variable length encoding with 7 bits of the number in each byte
Strings and binary data such as certificatesMostly a length followed by the content

V2G messages use a fixed set of EXI options agreed in the standard, so no options travel in the stream. Each message starts with the minimal EXI header, which is why an encoded V2G message usually begins with the byte 0x80.

Why a decoder needs the exact schema

  • The bits carry no names. The same bytes decoded with another grammar give another document or an error, never a helpful partial result.
  • The schemas of DIN SPEC 70121, ISO 15118-2 and ISO 15118-20 share many element names but have different grammars. A DIN SPEC 70121 message decoded with the ISO 15118-2 schema fails or produces nonsense, even where the two messages look alike on paper.
  • A schema is identified by its namespace. Adding or removing a single element between two drafts of a schema shifts the event codes of everything after it, so a stack built on a draft may send messages that only its own kind can read.
  • Decoders built from the schema, such as libcbv2g, also have fixed sizes for lists and binary fields. A message with more entries than the build allows is refused even when the schema would accept it. The message reference lists the repetition limits the analyzer accepts.

This is why the app handshake exists: supportedAppProtocolReq and its response are encoded with a small schema of their own that every generation shares, and only after it do both sides switch to the schema they agreed on. See The app protocol handshake.

The schemas

SchemaNamespaceV2GTP payload typeCarries
App handshakeurn:iso:15118:2:2010:AppProtocol0x8001supportedAppProtocolReq and supportedAppProtocolRes, for every generation
DIN SPEC 70121urn:din:70121:2012:MsgDef0x8001The DC session of the early CCS protocol
ISO 15118-2urn:iso:15118:2:2013:MsgDef0x8001AC and DC sessions of the first generation
ISO 15118-20 CommonMessagesurn:iso:std:iso:15118:-20:CommonMessages0x8002Session setup, authorization, services, schedules, power delivery and session stop
ISO 15118-20 AC, DC, ACDP and WPTurn:iso:std:iso:15118:-20:AC and the others0x8003 to 0x8006The messages of one energy transfer family, such as DC_ChargeLoopReq

DIN SPEC 70121 and ISO 15118-2 wrap every message in a V2G_Message with a Header (the SessionID) and a Body. ISO 15118-20 drops the wrapper and gives each message its own header with the SessionID and a timestamp.

The first generation shares payload type 0x8001 with the app handshake, so a decoder has to remember what was negotiated on the connection. ISO 15118-20 gives each schema its own payload type, so the V2GTP header alone says which grammar to use. When a capture has no handshake, the analyzer tries the schemas in turn.

Decode failures in a capture

When a message cannot be decoded, the analyzer still names it where it can: a small fallback decoder reads the header of the first generation schemas, so the row shows the message name with a note that the fields could not be read. When even that fails the row reads Undecodable EXI message. VT-02 reports every such message, and the Capture tool counts them, because the fields the checks, the negotiation and the curve need are missing.

What you seeUsual meaningWhat to do
Every message of a connection fails from the first one onThe wrong schema: the handshake is missing from the capture, or a stack sends a schema other than the one it announcedCapture from before the TCP connection opens, so the handshake is in the file
One or two messages fail in an otherwise readable sessionBytes missing from the capture (a TCP gap), or a message the sender built outside the schemaCheck the Capture tool for missing bytes first; if the bytes are complete, suspect the encoder of the sending side
Messages with long lists or large certificates failMore entries or bytes than the codec was built to holdCompare the counts in the raw message with the repetition limits in the message reference; report the case with the payload
Messages of a newer ISO 15118-20 amendment failA schema the codec does not include yet, such as the AC_DER messages of Amendment 1Nothing to fix in the session; the messages are simply not decoded
Encrypted, not decryptedNot an EXI problem: the session runs over TLS and no key log was loadedLoad the key log, see TLS in charging captures

The likely party on a VT-02 finding is the side that sent the message, on the assumption that the capture is complete. Rule the capture out before you blame the sender: a decoder cannot tell a message that was sent broken from one that reached the file incomplete.

The message codec (under Learn in the top bar) decodes a message pasted as hex, with or without its V2GTP header, and tries every schema the analyzer knows. It is the quickest way to see whether a payload decodes with another schema than the one the session negotiated.

Signatures over EXI

Plug and Charge signs parts of messages, for example the header of AuthorizationReq and the MeteringReceiptReq. The digest is computed over the EXI encoding of the signed element, not over XML text, so both sides must produce exactly the same bits for the same content. The standards fix how the signed element is encoded for that reason. A stack that encodes it differently produces a signature the other side rejects with FAILED_SignatureError, even though every field looks right in a decoder.

Sources

  • W3C Efficient XML Interchange (EXI) Format 1.0
  • ISO 15118-2:2014, message definitions and XML schemas
  • DIN SPEC 70121:2014-12, message definitions and XML schemas
  • ISO 15118-20:2022, XML schemas, V2GTP payload types (Table 14)
  • EVerest libcbv2g, the codec the analyzer runs in WebAssembly