Skip to content

Diameter Rx Interface

Overview

The Diameter Rx interface is used for policy control between the Application Function (AF) and the Policy and Charging Rules Function (PCRF). It enables applications to request QoS resources and provides service awareness to the policy control system.

Interface Specifications

Rx Interface (3GPP TS 29.214)

  • Application ID: 16777236
  • Vendor ID: 10415 (3GPP)
  • Commands:
  • AA-Request (AAR)
  • AA-Answer (AAA)
  • Re-Auth-Request (RAR)
  • Re-Auth-Answer (RAA)
  • Session-Termination-Request (STR)
  • Session-Termination-Answer (STA)
  • Abort-Session-Request (ASR)
  • Abort-Session-Answer (ASA)

Message Flows

Basic Session Flow

sequenceDiagram
    participant AF as Application Function
    participant PCRF as Policy Control Function

    AF->>PCRF: AAR (Initial Request)
    PCRF->>AF: AAA (Initial Answer)
    Note over AF,PCRF: Service Delivery
    PCRF->>AF: RAR (Policy Update)
    AF->>PCRF: RAA (Update Response)
    Note over AF,PCRF: Service Modification
    AF->>PCRF: STR (Session Termination)
    PCRF->>AF: STA (Termination Response)

Implementation Examples

Session Establishment

from telcoapi.diameter import rx

# Initialize Rx client
client = rx.RxClient(
    host="af.example.com",
    realm="example.com",
    destination_host="pcrf.example.com",
    destination_realm="example.com"
)

# Send AA-Request
aar = client.create_aar(
    session_id="session123",
    subscription_id="123456789",
    media_component=[{
        "media_component_number": 1,
        "media_type": "AUDIO",
        "codec_data": "PCMU",
        "bandwidth": {
            "upstream": 64000,
            "downstream": 64000
        }
    }]
)

response = client.send_aar(aar)
print(f"Session establishment response: {response}")

Policy Update Handling

# Handle Re-Auth-Request
@client.on_rar
def handle_rar(rar):
    # Process policy updates
    if rar.specific_action == "INDICATION_OF_LOSS_OF_BEARER":
        # Handle bearer loss
        notify_application_of_bearer_loss()

    # Send Re-Auth-Answer
    raa = client.create_raa(
        session_id=rar.session_id,
        result_code=2001  # DIAMETER_SUCCESS
    )
    client.send_raa(raa)

Session Termination

# Send session termination
str_request = client.create_str(
    session_id="session123",
    termination_cause="DIAMETER_LOGOUT"
)

response = client.send_str(str_request)
print(f"Session termination response: {response}")

Vendor Integration

Ericsson PCRF Integration

# Ericsson PCRF configuration
client.set_vendor_config({
    "vendor_id": 193,    # Ericsson vendor ID
    "product_name": "Ericsson PCRF",
    "firmware_revision": 1,
    "custom_avps": [
        {"code": 9001, "name": "Ericsson-Service-Awareness"},
        {"code": 9002, "name": "Ericsson-QoS-Profile"}
    ]
})

Huawei PCRF Integration

# Huawei configuration
client.set_vendor_config({
    "vendor_id": 2011,   # Huawei vendor ID
    "product_name": "Huawei PCRF",
    "firmware_revision": 1,
    "custom_avps": [
        {"code": 7001, "name": "Huawei-Media-Policy"},
        {"code": 7002, "name": "Huawei-Bandwidth-Policy"}
    ]
})

Error Handling

Common Error Scenarios

Result Code Name Description Action
5001 DIAMETER_ERROR_USER_UNKNOWN Unknown user Verify user identity
5002 DIAMETER_ERROR_INVALID_SERVICE_INFORMATION Invalid service info Check media components
5003 DIAMETER_ERROR_FILTER_RESTRICTIONS Filter error Review filter rules
5004 DIAMETER_ERROR_REQUESTED_SERVICE_NOT_AUTHORIZED Unauthorized service Check authorization

Error Handling Example

from telcoapi.diameter.exceptions import RxError

try:
    response = client.send_aar(aar_request)
except RxError as e:
    if e.result_code == 5002:  # INVALID_SERVICE_INFORMATION
        # Modify service information and retry
        modify_service_info(e.request)
        retry_request(e.request)
    else:
        # Log error and take appropriate action
        logger.error(f"Rx interface error: {e}")

Monitoring

Key Metrics

  1. Session Establishment Success Rate
  2. Policy Update Success Rate
  3. Average Response Time
  4. Active Sessions Count
  5. QoS Modification Rate

Monitoring Example

# Register monitoring callbacks
@client.on_metrics
def collect_rx_metrics(metrics):
    print(f"Session success rate: {metrics.success_rate}%")
    print(f"Average response time: {metrics.avg_response_time}ms")
    print(f"Active sessions: {metrics.active_sessions}")

Configuration Examples

Basic Configuration

rx_interface:
  host: "af.example.com"
  realm: "example.com"
  port: 3868
  application_id: 16777236
  vendor_id: 10415
  security:
    tls_enabled: true
    certificate: "/path/to/cert.pem"
    private_key: "/path/to/key.pem"
  peers:
    - host: "pcrf1.example.com"
      realm: "example.com"
      port: 3868
      role: "server"
    - host: "pcrf2.example.com"
      realm: "example.com"
      port: 3868
      role: "server"

Advanced Configuration

rx_interface:
  host: "af.example.com"
  realm: "example.com"
  port: 3868
  application_id: 16777236
  vendor_id: 10415
  vendor_specific:
    vendor_id: 193
    product_name: "Example AF Client"
    firmware_revision: 1
  security:
    tls_enabled: true
    certificate: "/path/to/cert.pem"
    private_key: "/path/to/key.pem"
    cipher_suites:
      - "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
      - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
  routing:
    strategy: "round_robin"
    failover_enabled: true
    retry_count: 3
    timeout: 5000
  session_management:
    cleanup_interval: 300
    max_sessions: 10000
    session_timeout: 3600
  peers:
    - host: "pcrf1.example.com"
      realm: "example.com"
      port: 3868
      role: "server"
      weight: 100
    - host: "pcrf2.example.com"
      realm: "example.com"
      port: 3868
      role: "server"
      weight: 100

Best Practices

  1. Implement proper session management
  2. Handle policy updates promptly
  3. Use secure transport (TLS)
  4. Implement proper failover
  5. Monitor session states
  6. Handle media component updates
  7. Implement QoS monitoring
  8. Use appropriate timeouts
  9. Handle multiple media streams
  10. Implement proper event notification