Diameter Protocol Message Structure

Diameter protocol is basically a Request/Response kind of protocol, hence this diameter protocol follows client/server model to communicate between nodes. In Diameter protocol, for every request message there will be an answer message for sure. For basic information related to Diameter protocol read article (Diameter Protocol Basics).

A Diameter protocol packet consists of Diameter message header along with variable number of AVP’s (Attribute-Value Pairs). Diameter message data is stored in form of AVP’s in the message.

Let’s have a look on the packet format of Diameter protocol as shown in the image.

Diameter_message_format

Description of various fields of Diameter Message Packet Format:

1) Version – This field length is of 1 byte and it indicates the version of Diameter Base Protocol which must be set to “1” (Only supported value).

2) Length – This field length is of 3 byte and it indicates the length of Diameter message including all the AVPs and Header Bytes.

3) Flags – This field length is of 1 byte and its value is assigned per bit-wise which are as follows:

Flag Bits Position:

01234567
RPETrrrr

a) The “R” (Request) Bit – If this field is set then this message is a request message else it’s an answer message.
b) The “P” (Proxiable) Bit – If this field is set then this message can be relayed, redirected or proxied else this message must be processed locally.
c) The “E” (Error) Bit – If this field is set then this message contains protocol error means this message is not correctly formatted which is described for this command. This bit must be set only in Answer Messages.
d) The “T” (Re-transmitted message) Bit – If this field is set then this message is a Re-transmission of another message for which answer is not yet received. This bit must be set only in Request Messages.
e) The “r” (Reserved) Bits –  These bits are reserved for the future use and these bits MUST be set to Zero and also these fields should be ignored by the receiver and should not be processed.

4) Command-Code – This field length is of 3 byte and its value is used to uniquely identify each Diameter command Request/Answer messages pair is assigned with a unique code known as the command code. Since, Request and Answer messages have the same command code, difference between those two is resolved by the “R” Bit flag which will be set in case of Request message. 0-255 values are reserved for backward compatibility with RADIUS protocol. The other values from 256-16777213 are permanent value and is allocated by IANA. For experimental and testing purposes, the values 16777214 and 16777215 (hex 0xFFFFFE and 0xFFFFFF) are reserved.
Examples: Command-Code for Device-watchdog message is 280, Capability-exchange message is 257 etc.

5) Application-ID – This field length is of 4 byte and its value is used to identify the diameter application for which this message is applicable. Since, the protocol also supports Auth-Application-Id AVP in some of the commands in which case both of these bytes will have the same values.

6) Hop-by-Hop Identifier – This field length is of 4 byte and its value is used to match the requests with their answers as both request and answer messages must contain its same value. In case of relaying and proxying agents, while forwarding a request message, its Hop-by-Hop Identifier is saved and replaced with another unique number which is restored to its original value when corresponding answer is received. Diameter agents will ignore the answer message if Hop-by-Hop Identifier value is mismatched.

7) End-to-End Identifier – This field length is of 4 byte and its value along with Origin-Host is used to detect duplicate messages. This identifier Must remain locally unique for minimum of 4 minutes, even across reboots this value must be preserved. Unlike Hop-by-Hop Identifier value, End-to-End Identifier value MUST Not be modified by any kind of Diameter Agents. Answer message Must set the same value received is corresponding request message.

8) Attribute-Value-Pairs – These are the basic units which contains the Data inside Diameter message. Its structure is as shown in above image. For more detail description related to AVPs (click here).

 

One thought on “Diameter Protocol Message Structure

  1. Just wanted to say I love reading through your blog and look forward to your your posts Hello, Neat post. There sa problem together with your web site in internet explorer, may check this.

Leave a Reply

Your email address will not be published. Required fields are marked *