JBoss.orgCommunity Documentation

Diameter User Guide


This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information.

In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. The Liberation Fonts set is also used in HTML editions if the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default.

Four typographic conventions are used to call attention to specific words and phrases. These conventions, and the circumstances they apply to, are as follows.

Mono-spaced Bold

Used to highlight system input, including shell commands, file names and paths. Also used to highlight key caps and key-combinations. For example:

The above includes a file name, a shell command and a key cap, all presented in Mono-spaced Bold and all distinguishable thanks to context.

Key-combinations can be distinguished from key caps by the hyphen connecting each part of a key-combination. For example:

The first sentence highlights the particular key cap to press. The second highlights two sets of three key caps, each set pressed simultaneously.

If source code is discussed, class names, methods, functions, variable names and returned values mentioned within a paragraph will be presented as above, in Mono-spaced Bold. For example:

Proportional Bold

This denotes words or phrases encountered on a system, including application names; dialogue box text; labelled buttons; check-box and radio button labels; menu titles and sub-menu titles. For example:

The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in Proportional Bold and all distinguishable by context.

Note the > shorthand used to indicate traversal through a menu and its sub-menus. This is to avoid the difficult-to-follow 'Select Mouse from the Preferences sub-menu in the System menu of the main menu bar' approach.

Mono-spaced Bold Italic or Proportional Bold Italic

Whether Mono-spaced Bold or Proportional Bold, the addition of Italics indicates replaceable or variable text. Italics denotes text you do not input literally or displayed text that changes depending on circumstance. For example:

Note the words in bold italics above username, domain.name, file-system, package, version and release. Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system.

Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term. For example:

If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! Please submit a report in the the Issue Tracker, against the product Diameter User Guide, or contact the authors.

When submitting a bug report, be sure to mention the manual's identifier: User_Guide

If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. If you have found an error, please include the section number and some of the surrounding text so we can find it easily.

Diameter is a computer networking protocol for Authentication, Authorization and Accounting (AAA), as defined in RFC3588. It is a successor to RADIUS, and has been designed to overcome certain RADIUS limitations:

  • No transport reliability and flexibility (Diameter uses TCP/SCTP instead of UDP).

  • No security within protocol (Diameter supports IPSec (mandatory) and TLS (optional)).

  • Limited address space for AVPs (Diameter uses 32-bit address space instead of 8-bit).

  • Only stateless mode is possible (Diameter supports both stateful and stateless modes).

  • Static peers (Diameter offers dynamic discovery, using DNS, SRV and NAPTR).

  • No peer alignment capabilities (Diameter introduces capabilities negotiation).

  • No support for transport layer failover. Diameter follows RFC3539, which introduces correct procedures.

  • Limited support for roaming (Diameter introduces mechanisms for secure and scalable roaming).

  • No extension possible (Diameter allows extension - new commands and AVPs to be defined).

Diameter offers all of the capabilities of the RADIUS protocol, and is compatible with RADIUS. It can also define extensions, or "Applications".

Each application may introduce new types of messages, AVP codes, and state machines. The Message and AVP codes are assigned by the IANA. Each application has its own Application ID and Vendor ID that is used to distinguish between applications. Application code is used to signal to other peers which operations are supported by the connecting peer (Capabilities Exchange / Negotiation).

Diameter is a byte based protocol. Each message has a fixed structure, which consists of two parts: header and payload.

The message header structure is common for every message. The content is fixed, as is the length. Message header content includes the code, application and certain bit flags, which helps identify the message in Diameter scope.

The message payload is built up of AVPs. Its content differs for each command and application, though they all define the Session-ID AVP as mandatory.


The header has the following fields:

Message Headers

Version

Indicates the Diameter protocol version. This value is always set to 1.

Message Length

Indicates the Diameter message length, including the header fields.

Flags

Composed by eight bits, to provide information regarding the message. The first four bits in the flags octet have the following meaning:

  • R = The message is a request (1) or an answer (0).

  • P = The message is proxiable (1) and may be proxied, relayed or redirected, or it must be processed locally (0).

  • E = The message is an error message (1) or a regular message (0).

  • T = The message is potentially being re-transmitted (1) or being sent for the first time (0).

The last four bits are reserved for future use, and should be set to 0.

Command Code

Indicates the command associated with the message.

Application-ID

Identifies the application to which the message is applicable for. The application is an authentication, accounting, or vendor specific application. The application-id in the header must be the same as what is contained in any relevant AVPs in the message.

Hop-by-Hop ID

A unique ID that is used to match requests and answers. The header field of the answer message must contain the same value present in the corresponding request. This is how answers are routed back to the peer that sent the message.

End-to-End ID

A time-limited unique ID that is used to to detect duplicate messages. The ID must be unique for at least four minutes. The answer message originator must ensure that this header contains the same value present in the corresponding request.

The message payload is built up from AVPs. Each AVP has a similar structure: a header, and encoded data. Data can be simple (eg, integer, long) or complex (another encoded AVP).


Payload AVPs

AVP Code

Uniquely identifies the attribute, by combining the specified code with the value contained within the Vendor-ID header field.

AVP numbers 1 to 255 are reserved for RADIUS backwards compatibility, and do not require the Vendor-ID header field. AVP numbers 256 and above are used exclusively for the Diameter protocol, and are allocated by IANA.

Flags

Bit flags that specify how each attribute must be handled. Flags octets have the following structure: V M P r r r r r.

A full description is available in Section 4.1 of RFC3588.

The first three bits have the following meaning:

V

If set, indicates that optional octets (Vendor-ID) is present in AVP header.

M

If set, it indicates that receiveing peer must understand this AVP or send error answer.

P

If set, it indicates the need for encryption for end-to-end security.

The last 5 bits are reserved for future use, and should be set to 0.

AVP Length

Indicates the number of octets in the AVP, including the following information:

  • AVP Code

  • AVP Length

  • AVP Flags

  • Vendor-ID field (if present)

  • AVP Data

Vendor-ID

An optional octet that identifies the AVP in application space. AVP code and AVP Vendor-ID create a unique identifier for the AVP.

The Diameter Stack is the core component of the presented Diameter solution. It performs all necessary tasks to allow user interaction with the Diameter network. It manages the state of diameter peers and allows to route messages between them. For more details, refer to RFC 3588.

The Diameter Stack currently supports the following application sessions:

  • Base

  • Credit Control Application (CCA)

  • Sh

  • Ro

  • Rf

  • Cx/Dx

  • Gx

  • Gq'

  • Rx

This section provides instructions on how to obtain and build the Mobicents Diameter Stack from source code.

  1. Downloading the source code

    Use SVN to checkout a specific release source, the base URL is http://mobicents.googlecode.com/svn/tags/servers/diameter/core/jdiameter, then add the specific release version, lets consider 1.4.0.FINAL.

    [usr]$ svn co http://mobicents.googlecode.com/svn/tags/servers/diameter/core/jdiameter/1.4.0.FINAL jdiameter-1.4.0.FINAL
  2. Building the source code

    Important

    Maven 2.0.9 (or higher) is used to build the release. Instructions for using Maven2, including install, can be found at http://maven.apache.org

    Use Maven to build the deployable unit binary.

    						[usr]$ cd jdiameter-1.4.0.FINAL
    						[usr]$ mvn install
    					

    Once the process finishes you should have the JAR files deployed in maven archive.

Follow the process in Section 2.2.2.1, “Release Source Code Building”, replacing the SVN source code URL with http://mobicents.googlecode.com/svn/trunk/servers/diameter/core/jdiameter.

The stack is initially configured by parsing an XML file. The top level structure of the file is described below. Further explanation of each child element, and the applicable attributes, is provided later in this section.


<Configuration xmlns="http://www.jdiameter.org/jdiameter-server">

    <LocalPeer></LocalPeer>
    <Parameters></Parameters>
    <Network></Network>
    <Extensions></Extensions>

</Configuration>

<LocalPeer>
    <URI value="aaa://localhost:3868"/>
    <IPAddresses>
        <IPAddress value="127.0.0.1"/>
    </IPAddresses>

    <Realm value="mobicents.org"/>
    <VendorID value="193"/>
    <ProductName value="jDiameter"/>
    <FirmwareRevision value="1"/>

    <OverloadMonitor>
        <Entry index="1" lowThreshold="0.5" highThreshold="0.6">
            <ApplicationID>
                <VendorId value="193"/>
                <AuthApplId value="0"/>
                <AcctApplId value="19302"/>
            </ApplicationID>
        </Entry>
    </OverloadMonitor>
    <Applications>
        <ApplicationID>
            <VendorId value="193"/>
            <AuthApplId value="0"/>
            <AcctApplId value="19302"/>
        </ApplicationID>
    </Applications>
</LocalPeer>

The <LocalPeer> element contains parameters that affect the local Diameter peer. The available elements and attributes are listed for reference.

<LocalPeer> Elements and Attributes

<URI>

Specifies the URI for the local peer. The URI has the following format: "aaa://FQDN:port".

<IPAddresses>

Contains one or more child <IPAddress> element, which contain a single, valid IP address for the local peer, stored in the value attribute of the IPAddress.

<Realm>

Specifies the realm of the local peer, using the value attribute.

<VendorID>

Specifies a numeric identifier that corresponds to the vendor ID allocated by IANA.

<ProductName>

Specifies the name of the local peer product.

<FirmwareRevision>

Specifies the version of the firmware.

<OverloadMonitor>

Optional parent element containing child elements that specify settings relating to the Overload Monitor.

<Entry>

Supports <ApplicationID> child elements that specify the ID of the tracked application(s). It also supports the following properties:

<ApplicationID>

Parent element containing child elements that specify information about the application. The child elements create a unique application identifier. The child elements are:

<Applications>

Contains a child element <ApplicationID>, which defines the list of default supported applications. It is used for the server side, when the stack is configured to accept incoming calls and there is an empty list of preconfigured peers (server is configured to accept any connection).


<Parameters>

    <AcceptUndefinedPeer value="true"/>
    <DuplicateProtection value="true"/>
  <DuplicateTimer value="240000"/>
  <DuplicateSize value="5000"/>
    <UseUriAsFqdn value="true"/> <!-- Needed for Ericsson SDK Emulator -->
    <QueueSize value="10000"/>
    <MessageTimeOut value="60000"/>
    <StopTimeOut value="10000"/>
    <CeaTimeOut value="10000"/>
    <IacTimeOut value="30000"/>
    <DwaTimeOut value="10000"/>
    <DpaTimeOut value="5000"/>
    <RecTimeOut value="10000"/>

    <Concurrent>
        <Entity name="ThreadGroup" size="64"/>
        <Entity name="ProcessingMessageTimer" size="1"/>
        <Entity name="DuplicationMessageTimer" size="1"/>
        <Entity name="RedirectMessageTimer" size="1"/>
        <Entity name="PeerOverloadTimer" size="1"/>
        <Entity name="ConnectionTimer" size="1"/>
        <Entity name="StatisticTimer" size="1"/>
        <Entity name="ApplicationSession" size="16"/>
    </Concurrent>

</Parameters>

The <Parameters> element contains elements that specify parameters for the Diameter stack. The available elements and attributes are listed for reference. If not specified otherwise, each tag supports a single property - "value", which indicates the value of the tag.

<Parameters> Elements and Attributes

<AcceptUndefinedPeer>

Specifies whether the stack will accept connections from undefined peers. The default value is false.

<DuplicateProtection>

Specifies whether duplicate message protection is enabled. The default value is false.

<DuplicateTimer>

Specifies the time each duplicate message is valid for (in extreme cases, it can live up to 2 * DuplicateTimer - 1 milliseconds). The default, minimum value is 240000 (4 minutes in milliseconds).

<DuplicateSize>

Specifies the number of requests stored for duplicate protection. The default value is 5000.

<UseUriAsFqdn>

Determines whether the URI should be used as FQDN. If it is set to true, the stack expects the destination/origin host to be in the format of "aaa://isdn.domain.com:3868" rather than the normal "isdn.domain.com". The default value is false.

<QueueSize>

Determines how many tasks the peer state machine can have before rejecting the next task. This queue contains FSM events and messaging.

<MessageTimeOut>

Determines the timeout for messages other than protocol FSM messages. The delay is in milliseconds.

<StopTimeOut>

Determines how long the stack waits for all resources to stop. The delays are in milliseconds.

<CeaTimeOut>

Determines how long it takes for CER/CEA exchanges to timeout if there is no response. The delays are in milliseconds.

<IacTimeOut>

Determines how long the stack waits to retry the communication with a peer that has stopped answering DWR messages. The delay is in milliseconds.

<DwaTimeOut>

Determines how long it takes for a DWR/DWA exchange to timeout if there is no response. The delay is in milliseconds.

<DpaTimeOut>

Determines how long it takes for a DPR/DPA exchange to timeout if there is no response. The delay is in milliseconds.

<RecTimeOut>

Determines how long it takes for the reconnection procedure to timeout. The delay is in milliseconds.

<Concurrent />

Controls the thread pool sizes for different aspects of the stack. It supports multiple Entity child elements. Entity elements configure thread groups. These elements support the following properties:

The default supported entities are:


<Network>

    <Peers>
        <!-- This peer is a server, if it's a client attempt_connect should be set to false -->
        <Peer name="aaa://127.0.0.1:3868" attempt_connect="true" rating="1"/>
    </Peers>

    <Realms>
        <Realm name="mobicents.org" peers="127.0.0.1" local_action="LOCAL" dynamic="false" exp_time="1">
            <ApplicationID>
                <VendorId value="193"/>
                <AuthApplId value="0"/>
                <AcctApplId value="19302"/>
            </ApplicationID>
        </Realm>
    </Realms>

</Network>

The <Network> element contains elements that specify parameters for external peers. The available elements and attributes are listed for reference.

Below is an example configuration file for a server supporting the CCA, Sh and Ro Applications:


<?xml version="1.0"?>
<Configuration xmlns="http://www.jdiameter.org/jdiameter-server">

    <LocalPeer>
        <URI value="aaa://127.0.0.1:3868" />
        <Realm value="mobicents.org" />
        <VendorID value="193" />
        <ProductName value="jDiameter" />
        <FirmwareRevision value="1" />
        <OverloadMonitor>
            <Entry index="1" lowThreshold="0.5" highThreshold="0.6">
                <ApplicationID>
                    <VendorId value="193" />
                    <AuthApplId value="0" />
                    <AcctApplId value="19302" />
                </ApplicationID>
            </Entry>
        </OverloadMonitor>
    </LocalPeer>

    <Parameters>
        <AcceptUndefinedPeer value="true" />
        <DuplicateProtection value="true" />
    <DuplicateTimer value="240000" />
    <DuplicateSize value="5000" />
        <UseUriAsFqdn value="false" /> <!-- Needed for Ericsson Emulator (set to true) -->
        <QueueSize value="10000" />
        <MessageTimeOut value="60000" />
        <StopTimeOut value="10000" />
        <CeaTimeOut value="10000" />
        <IacTimeOut value="30000" />
        <DwaTimeOut value="10000" />
        <DpaTimeOut value="5000" />
        <RecTimeOut value="10000" />
        <Concurrent>
             <Entity name="ThreadGroup" size="64"/>
             <Entity name="ProcessingMessageTimer" size="1"/>
             <Entity name="DuplicationMessageTimer" size="1"/>
             <Entity name="RedirectMessageTimer" size="1"/>
             <Entity name="PeerOverloadTimer" size="1"/>
             <Entity name="ConnectionTimer" size="1"/>
             <Entity name="StatisticTimer" size="1"/>
             <Entity name="ApplicationSession" size="16"/>
        </Concurrent>
    </Parameters>

    <Network>
        <Peers>
            <Peer name="aaa://127.0.0.1:1218" attempt_connect="false" rating="1" />
        </Peers>
        <Realms>
            <!-- CCA -->
            <Realm name="mobicents.org" peers="127.0.0.1" local_action="LOCAL" 
                dynamic="false" exp_time="1">
                <ApplicationID>
                    <VendorId value="0" />
                    <AuthApplId value="4" />
                    <AcctApplId value="0" />
                </ApplicationID>
            </Realm>
            
            <!-- Sh -->
            <Realm name="mobicents.org" peers="127.0.0.1" local_action="LOCAL" 
                dynamic="false" exp_time="1">
                <ApplicationID>
                    <VendorId value="10415" />
                    <AuthApplId value="16777217" />
                    <AcctApplId value="0" />
                </ApplicationID>
            </Realm>

            <!-- Ro -->
            <Realm name="mobicents.org" peers="127.0.0.1" local_action="LOCAL" 
                dynamic="false" exp_time="1">
                <ApplicationID>
                    <VendorId value="10415" />
                    <AuthApplId value="4" />
                    <AcctApplId value="0" />
                </ApplicationID>
            </Realm>
        </Realms>
    </Network>

    <Extensions />

</Configuration>

The following list defines the requirements for enabling stack cluster mode

Diameter stack is built with the following basic components:

SessionFactory provides the stack user with access to session objects. It manages registered application session factories in order to allow for the creation of specific application sessions. A Session Factory instance can be obtained from the stack using the getSessionFactory() method. The base SessionFactory interface is defined below:

package org.jdiameter.api;


import org.jdiameter.api.app.AppSession;
public interface SessionFactory {
    RawSession getNewRawSession() throws InternalException;
    Session getNewSession() throws InternalException;
    Session getNewSession(String sessionId) throws InternalException;
    <extends AppSession> T getNewAppSession(ApplicationId applicationId, 
        Class<? extends AppSession> userSession) throws InternalException;
    <extends AppSession> T getNewAppSession(String sessionId, ApplicationId
        applicationId, Class<? extends AppSession> userSession) throws InternalException;
}

However, since the stack is extensible, it is safe to cast the SessionFactory object to this interface:

package org.jdiameter.client.api;



public interface ISessionFactory extends SessionFactory {
    <extends AppSession> T getNewAppSession(String sessionId, 
        ApplicationId applicationId, java.lang.Class<? extends AppSession> 
        aClass, Object... args) throws InternalException;
    void registerAppFacory(Class<? extends AppSession> sessionClass, 
        IAppSessionFactory factory);
    void unRegisterAppFacory(Class<? extends AppSession> sessionClass);
    IConcurrentFactory getConcurrentFactory();
}
RawSession getNewRawSession() throws InternalException;

This method creates a RawSession. Raw sessions are meant as handles for code performing part of the routing decision on the stack's, such as rely agents for instance.

Session getNewSession() throws InternalException;

This method creates a session that acts as the endpoint for peer communication (for a given session ID). It declares the method that works with the Request and Answer objects. A session created with this method has an autogenerated ID. It should be considered as a client session.

Session getNewSession(String sessionId) throws InternalException;

As above. However, the created session has an ID equal to that passsed as an argument. This created session should be considered a server session.

<T extends AppSession> T getNewAppSession(ApplicationId applicationId, Class<? extends AppSession> userSession) throws InternalException;

This method creates a new specific application session, identified by the application ID and class of the session passed. The session ID is generated by implementation. New application sessions should be considered as client sessions. It is safe to type cast the return value to class passed as an argument. This method delegates the call to a specific application session factory.

<T extends AppSession> T getNewAppSession(String sessionId, ApplicationId applicationId, Class<? extends AppSession> userSession) throws InternalException;

As above. However, the session Id is equal to the argument passed. New sessions should be considered server sessions.

<T extends AppSession> T getNewAppSession(String sessionId, ApplicationId applicationId, java.lang.Class<? extends AppSession> aClass, Object... args) throws InternalException;

As above. However, it allows the stack to pass some additional arguments. Passed values are implementation specifc.

void registerAppFacory(Class<? extends AppSession> sessionClass, IAppSessionFactory factory);

Registers the factory for a certain sessionClass. This factory will receive a delegated call when ever the getNewAppSession method is called with an application class matching one from the register method.

void unRegisterAppFacory(Class<? extends AppSession> sessionClass);

Removes the application session factory registered for the sessionClass.



RawSessions, Sessions and ApplicationSessions provide the means for dispatching and receiving messages. Specific implementation of ApplicationSession may provide non standard methods.

The RawSession and the Session life span is controlled entirely by the application. However, the ApplicationSession life time depends on the implemented state machine.

RawSession is defined as follows:

public interface BaseSession extends Wrapper, Serializable {

 
    long getCreationTime();
    long getLastAccessedTime();
    boolean isValid();
    Future<Message> send(Message message) throws InternalException, 
        IllegalDiameterStateException, RouteException, OverloadException;
    Future<Message> send(Message message, long timeOut, TimeUnit timeUnit) 
        throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
    void release();
}
public interface RawSession extends BaseSession {
    Message createMessage(int commandCode, ApplicationId applicationId, Avp... avp);
    Message createMessage(int commandCode, ApplicationId applicationId, 
        long hopByHopIdentifier, long endToEndIdentifier, Avp... avp);
    Message createMessage(Message message, boolean copyAvps);
    void send(Message message, EventListener<Message, Message> listener) 
        throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
    void send(Message message, EventListener<Message, Message> listener,
        long timeOut, TimeUnit timeUnit) throws InternalException, 
        IllegalDiameterStateException, RouteException, OverloadException;
}
long getCreationTime();

Returns the time stamp of this session creation.

long getLastAccessedTime();

Returns the time stamp indicating the last sent or received operation.

boolean isValid();

Returns true when this session is still valid (ie, release() has not been called).

void release();

Application calls this method to inform the user that the session should free any associated resource - it shall not be used anymore.

Future<Message> send(Message message)

Sends a message in async mode. The Future reference provides the means of accessing the answer once it is received

void send(Message message, EventListener<Message, Message> listener, long timeOut, TimeUnit timeUnit)

As above. Allows to specify the time out value for send operations.

Message createMessage(int commandCode, ApplicationId applicationId, Avp... avp);

Creates a Diameter message. It should be explicitly set either as a request or answer. Passed parameters are used to build messages.

Message createMessage(int commandCode, ApplicationId applicationId, long hopByHopIdentifier, long endToEndIdentifier, Avp... avp);

As above. However, it also allows for the Hop-by-Hop and End-to-End Identifiers in the message header to be set. This method should be used to create answers.

Message createMessage(Message message, boolean copyAvps);

Clones a message and returns the created object. The copyAvps parameter defines whether basic AVPs (Session, Route and Proxy information) should be copied to the new object.

void send(Message message, EventListener<Message, Message> listener)

Sends a message. The answer will be delivered by the specified listener

void send(Message message, EventListener<Message, Message> listener, long timeOut, TimeUnit timeUnit)

As above. It also allows for the answer to be passed after timeout.

Session defines similar methods, with exactly the same purpose:

public interface Session extends BaseSession {

    String getSessionId();
    void setRequestListener(NetworkReqListener listener);
    Request createRequest(int commandCode, ApplicationId appId, String destRealm);
    Request createRequest(int commandCode, ApplicationId appId, String destRealm, String destHost);
    Request createRequest(Request prevRequest);
    void send(Message message, EventListener<Request, Answer> listener) 
        throws InternalException, IllegalDiameterStateException, RouteException, OverloadException;
    void send(Message message, EventListener<Request, Answer> listener, long timeOut,
        TimeUnit timeUnit) throws InternalException, IllegalDiameterStateException, 
        RouteException, OverloadException;
}

Validator is one of the Stack features. The primary purpose of the Validator is to detect malformed messages, such as an Answer message containing a Destination-Host Attribute Value Pair (AVP).

The Validator is capable of validating multi-leveled, grouped AVPs, excluding the following content types:

The Validator is only capable of checking structural integrity, not the content of the message.

The Validator performs the following checks:

The Validator is called by the stack implementation. It is invoked after the message is received, but before it is dispatched to a remote peer.

The Validator is configured with a single XML file. This file contains the structure definition for both messages and AVPs.

Upon creation of the Diameter Stack, the validator is initialized. It performs the initialization by looking up the dictionary.xml file in classpath.

The configuration file has the following structure:



<dictonary>
    <validator enabled="true|false" sendLevel="OFF|MESSAGE|ALL" receiveLevel="OFF|MESSAGE|ALL" />
    <vendor name="" vendor-id="" code=""/>
    <typedefn type-name="" type-parent=""/>
    <application id="" name="">
        <avp ...>
            <type type-name=""/>
            <enum name="" code=""/>
            <grouped>
                <gavp name=""/>
            <grouped/>
        <avp/>
        <command name="" code="" request="true|false"/>
        <avp ...>
            <type type-name=""/>
            <enum name="" code=""/>
            <grouped>
                <gavp name=""/>
            <grouped/>
        <avp/>
    <application>
<dictionary/>

<typedefn>

Defines the simple Attribute Value Pair (AVP) types. The element supports the following required attributes:

type-name

Specifies a type name in accordance with the acceptable base types defined in RFC 3588. For example; "Enumerated", "OctetString", "Integer32".

type-parent

Specifies the parent type name used to define the base characteristics of the type. The values are restricted to defined <typedefn> elements. For example; "OctetString", "UTF8String", "IPAddress".


<application>

Defines the specific applications used within the dictionary. Two child elements are supported by <application>: <avp> and <command>.

The <application> element supports the following attributes:

id

Specifies the unique ID allocated to the application. The attribute is used in all messages and forms part of the message header.

name

Optional attribute that specifies the logical name of the application.

uri

Optional attribute that specifies a link to additional application information.


<avp>

Element containing information necessary to configure the Attribute Value Pairs. Table 2.2, “<avp> Attributes” contains the complete list of supported attributes, and their available values (if applicable).

The <avp> element supports a number of child elements that are used to set finer parameters for the individual AVP. The supported elements are <type>, <enum>, and <grouped>.

Note

Different sets of elements are supported by <avp> depending on its position in the dictionary.xml file.


<type>

Child element of <avp> that is used to match the AVP with the AVP type as defined in the <typedefn> element. The element supports the following mandatory attribute:

type-name

Specifies the type-name of the element. This is used to match the type-name value in the <typedefn> element.

Note

<type> is ignored if the <avp> element contains the <grouped> element.

<enum>

Child element of <avp> that specifies the enumeration value for the specified AVP. <enum> is used only when the type-name attribute of <type> is specified. The element supports the following mandatory attributes:

name

Specifies the name of a constant value that applies to the AVP.

code

Specifies the integer value associated with the name of the constant. The value is passed as a value of the AVP, and maps to the name attribute.

Note

<enum> is ignored if the <avp> element contains the <grouped> element.

<grouped>

Child element of <avp> that specifies the AVP is a grouped type. A grouped AVP is one that has no <typedefn> element present. The element does not support any attributes, however the <gavp> element is allowed as a child element.

The <gavp>, which specifies a reference to a grouped AVP, supports one mandatory attribute:

name

Specifies the name of the grouped AVP member. The value must match the defined AVP name.



<command>

Specifies the command for the application. The element supports the <avp> element, which specifies the structure of the command. The element supports the following attributes:

name

Optional parameter that specifies the message name for descriptive purposes.

code

Mandatory parameter that specifies the integer code of the message.

request

Mandatory parameter that specifies whether the declared command is a request or answer. The available values are "true" (request) or "false" (answer).

Note

If the <avp> element is specified in <command>, it does not support any child elements. The <avp> element only refers to defined AVPs when used in this context.


The Validator API defines methods to access its database of AVPs and check if the AVP and message have the proper structure.

The Validator is currently message oriented. This means that it declares methods that center on message consistency checks. The class containing all validation logic is org.jdiameter.common.impl.validation.DiameterMessageValidator. It exposes the following methods:

A simple example of a Validator use case is shown below:


The Multiplexer (MUX) is designed as a stack wrapper. It serves two purposes:

Expose Stack

It exposes the stack and allows it to be shared between multiple listeners. The stack follows the life cycle of the MUX. It is created and destroyed with MUX.

Expose Management Operations

Exposes the management operations for JMX clients, one of them being the Jopr Console. For specific information please refer to the Mobicents Diameter Management Console User Guide.

This section provides instructions on how to obtain and build the Mobicents Diameter MUX from source code.

  1. Downloading the source code

    Use SVN to checkout a specific release source. The base URL is http://mobicents.googlecode.com/svn/tags/servers/diameter/core/mux. Then add the specific release version, for example 1.4.0.FINAL.

    [usr]$ svn co http://mobicents.googlecode.com/svn/tags/servers/diameter/core/mux/1.4.0.FINAL mux-1.4.0.FINAL
  2. Building the source code

    Important

    Maven 2.0.9 (or higher) is used to build the release. Instructions for using Maven2, including installation, can be found at http://maven.apache.org.

    Use Maven to build the deployable unit binary.

    						[usr]$ cd mux-1.4.0.FINAL
    						[usr]$ mvn install
    					

    Once the process finishes you should have the SAR built. If the JBOSS_HOME environment variable is set, the SAR will be deployed in the container after execution.

Note

By default Mobicents Diameter MUX; deploys in the JBoss Application Server v5.x SAR. To change it, run maven with the profile switch command: -Pjboss4.

Follow the Section 3.2.2.1, “Release Source Code Building” procedure, replacing the SVN source code URL with http://mobicents.googlecode.com/svn/trunk/servers/diameter/core/mux.

The Diameter MUX capabilities are defined by the MBean interface org.mobicents.diameter.stack.DiameterStackMultiplexerMBean. This interface defines two types of methods:

The methods below are of interest to a Diameter MUX user:

The listener interface is defined below:



package org.mobicents.diameter.stack;
import java.io.Serializable;
import org.jdiameter.api.Answer;
import org.jdiameter.api.EventListener;
import org.jdiameter.api.NetworkReqListener;
import org.jdiameter.api.Request;
public interface DiameterListener extends NetworkReqListener, Serializable, 
    EventListener<Request, Answer>
{
}
    

MUX can be used as follows:

public class DiameterActor implements DiameterListener

{
    private ObjectName diameterMultiplexerObjectName = null;
    private DiameterStackMultiplexerMBean diameterMux = null;
    private synchronized void initStack() throws Exception {
        this.diameterMultiplexerObjectName = 
            new ObjectName("diameter.mobicents:service=DiameterStackMultiplexer");
        Object[] params = new Object[]{};
        String[] signature = new String[]{};
        String operation = "getMultiplexerMBean";
        this.diameterMux=mbeanServer.invoke(this.diameterMultiplexerObjectName, operation,
            params, signature);
        long acctAppIds = new long[]{19312L};
        long acctVendorIds = new long[]{193L};
        long authAppIds = new long[]{4L};
        long authVendorIds = new long[]{0L};
        List<ApplicationId> appIds = new ArrayList<ApplicationId>();
        for(int index = 0;index<acctAppIds.length;index++) {
            appIds.add(ApplicationId.createByAccAppId(acctVendorIds[index], acctAppIds[index]));
        }
        for(int index = 0;index<authAppIds.length;index++) {
            appIds.add(ApplicationId.createByAuthAppId(authVendorIds[index], authAppIds[index]));
        }
        this.diameterMux.registerListener(this, appIds.toArray(new ApplicationId[appIds.size()]));
        this.stack = this.diameterMux.getStack();
        this.messageTimeout = stack.getMetaData().getConfiguration().getLongValue(
            MessageTimeOut.ordinal(), (Long) MessageTimeOut.defValue());
    }
}

The Dictionary is part of the MUX package. Its purpose is to provide unified access to information regarding AVP structure, content and definition. It is configured with an XML file: dictionary.xml.

Dictionary logic is contained in the org.mobicents.diameter.dictionary.AvpDictionary class. It exposes the following methods:

Dictionary uses a POJO class to provide access to stored information: org.mobicents.diameter.dictionary.AvpRepresentation. It exposes the following methods:

The Diameter MUX Dictionary can be used as follows:

public static void addAvp(Message msg, int avpCode, long vendorId, AvpSet set, Object avp) {

    AvpRepresentation avpRep = AvpDictionary.INSTANCE.getAvp(avpCode, vendorId);
    if(avpRep != null) {
        DiameterAvpType avpType = DiameterAvpType.fromString(avpRep.getType());
        boolean isMandatoryAvp = avpRep.isMandatory();
        boolean isProtectedAvp = avpRep.isProtected();
        if(avp instanceof byte[]) {
            setAvpAsRaw(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp, (byte[]) avp);
        }
        else
        {
            switch (avpType.getType()) {
            case DiameterAvpType._ADDRESS:
            case DiameterAvpType._DIAMETER_IDENTITY:
            case DiameterAvpType._DIAMETER_URI:
            case DiameterAvpType._IP_FILTER_RULE:
            case DiameterAvpType._OCTET_STRING:
            case DiameterAvpType._QOS_FILTER_RULE:
                setAvpAsOctetString(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    avp.toString());
                break;
            case DiameterAvpType._ENUMERATED:
            case DiameterAvpType._INTEGER_32:
                setAvpAsInteger32(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Integer) avp);
                break;
            case DiameterAvpType._FLOAT_32:
                setAvpAsFloat32(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Float) avp);
                break;
            case DiameterAvpType._FLOAT_64:
                setAvpAsFloat64(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Float) avp);
                break;
            case DiameterAvpType._GROUPED:
                setAvpAsGrouped(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (DiameterAvp[]) avp);
                break;
            case DiameterAvpType._INTEGER_64:
                setAvpAsInteger64(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Long) avp);
                break;
            case DiameterAvpType._TIME:
                setAvpAsTime(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Date) avp);
                break;
            case DiameterAvpType._UNSIGNED_32:
                setAvpAsUnsigned32(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Long) avp);
                break;
            case DiameterAvpType._UNSIGNED_64:
                setAvpAsUnsigned64(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (Long) avp);
                break;
            case DiameterAvpType._UTF8_STRING:
                setAvpAsUTF8String(msg, avpCode, vendorId, set, isMandatoryAvp, isProtectedAvp,
                    (String) avp);
                break;
            }
        }
    }
}

Revision History
Revision 1.0Thu Mar 11 2010Bartosz Baranowski, Alexandre Mendonça
Creation of the Mobicents Diameter User Guide.
Revision 1.0Mon July 12 2010Bartosz Baranowski, Alexandre Mendonça
Creation of the Mobicents Diameter User Guide.