Skip to main content

CAMEL Gateway Configuration Guide

Overview

The CAMEL Gateway (CAMELGW) mode turns OmniSS7 into an Intelligent Network (IN) platform that provides real-time call control and charging using the CAMEL Application Part (CAP) protocol. OmniSS7 acts as the gsmSCF (Service Control Function), receiving triggers from the gsmSSF in the MSC/VLR/GMSC and driving charging decisions through CGrateS.

CAMEL Request Builder Overview

What is CAMEL?

CAMEL (Customized Applications for Mobile network Enhanced Logic) is a set of standards that work on either a GSM core network or a UMTS network. It lets operators provide services that require real-time control of calls, such as:

  • Prepaid calling - Real-time balance checking and charging
  • Premium rate services - Special billing for value-added services
  • Call routing control - Dynamic destination routing based on time/location
  • Virtual private networks - Corporate numbering plans
  • Call screening - Allow/block calls based on criteria

CAP Protocol Versions

OmniSS7 CAMELGW supports multiple CAP versions. The version controls the application-context OID carried in the TCAP dialogue:

VersionPhaseApplication-Context OID
CAP v1CAMEL Phase 10.4.0.0.1.0.50.0
CAP v2CAMEL Phase 20.4.0.0.1.0.50.1
CAP v3CAMEL Phase 30.4.0.0.1.21.3.4
CAP v4CAMEL Phase 40.4.0.0.1.23.3.4

Default: CAP v2 (most widely deployed). The incoming version is auto-detected from the InitialDP dialogue portion and reused when generating the response, so responses match each MSC's CAP version.


Architecture

Call Flow Example


Configuration

Prerequisites

  • OmniSS7 installed and running
  • M3UA connectivity to MSC/GMSC (gsmSSF)
  • A CGrateS instance reachable over JSON-RPC (optional, for real-time charging)

Enable CAMEL Gateway Mode

CAMEL processing is controlled by two independent flags. cap_client_enabled brings up the CAP/M3UA client and CAMEL session components; cgrates_enabled turns on the CGrateS charging integration behind the backend. Configure these in config/runtime.exs:

config :omniss7,
# Bring up the CAP/CAMEL client (M3UA ASP, SessionStore, request handling)
cap_client_enabled: true,

# Other independent modes (set as needed for your deployment)
map_client_enabled: false,
smsc_mode_enabled: false,

# CAP version used for outgoing requests / dialogue (:v1 | :v2 | :v3 | :v4)
cap_version: :v2,

# CGrateS charging integration
cgrates_enabled: true,

# M3UA connection for CAP (connect as ASP toward the MSC/GMSC gsmSSF)
cap_client_m3ua: %{
routing_context: 1,
opc: 5013,
dpc: 5011
}

Note on cap_client_m3ua: the CAMEL client reads only :routing_context, :opc, and :dpc from this map. Any additional keys are ignored by the CAP client. The M3UA ASP process name is fixed internally as :camelgw_client_asp.

There is no camelgw_mode_enabled, hlr_mode_enabled, or smsc_mode_enabled-for-CAMEL flag. The only flags that gate CAMEL behaviour are cap_client_enabled and cgrates_enabled.

Mode Flags

KeyDefaultPurpose
cap_client_enabledfalseStarts the CAP/CAMEL client (M3UA ASP, SessionStore, CAP request handling)
cgrates_enabledfalseEnables CGrateS charging integration in CAMELGW.Backend
cap_version:v2Default CAP version / dialogue OID for outgoing requests
map_client_enabledfalseIndependent MAP client mode
smsc_mode_enabledfalseIndependent SMSc mode (requires MAP client)

CGrateS Charging Parameters

KeyDefaultPurpose
cgrates_enabledfalseMaster switch for CGrateS integration
cgrates_urlhttp://localhost:2080/jsonrpcCGrateS JSON-RPC endpoint
cgrates_tenantcgrates.orgTenant used on every SessionS event
cgrates_request_type*prepaidCGrateS request type (e.g. *prepaid, *postpaid)
cgrates_timeout5000HTTP request timeout in milliseconds

Configure Web UI Pages

The Web UI exposes the CAMEL pages through the control panel. These are configured in config/config.exs:

config :control_panel,
use_additional_pages: [
{SS7.Web.EventsLive, "/events", "SS7 Events"},
{SS7.Web.M3UAStatusLive, "/m3ua", "Peers"},
{SS7.Web.CAMELSessionsLive, "/camel_sessions", "CAMEL Sessions"},
{SS7.Web.CAMELRequestLive, "/camel_request", "CAMEL Request Builder"}
],
page_order: [
"/events", "/m3ua", "/camel_sessions", "/camel_request",
"/application", "/configuration"
]
Page labelRouteModule
Peers/m3uaSS7.Web.M3UAStatusLive
CAMEL Sessions/camel_sessionsSS7.Web.CAMELSessionsLive
CAMEL Request Builder/camel_requestSS7.Web.CAMELRequestLive

CAP Operations Supported

CAP operations are identified by name and direction. Note that the codebase is internally inconsistent on some CAP opcode numbers (the event-log opcode map and the request generator disagree on a few operations), so operations below are described by name and endpoint. Where an opcode is cited, it is the one cap_request_generator.ex actually emits.

Incoming Operations (gsmSSF → gsmSCF)

Handled in cap_request.ex (handle_request/1 dispatch on the decoded TCAP component opcode):

OperationHandlerNotes
InitialDPhandle_initial_dp/1Call setup notification; triggers CGrateS InitiateSession. Accepted at opcode 0, and also at opcode 60 (treated as InitialDP/InitialDPSMS)
AssistRequestInstructionshandle_assist_request_instructions/1Acknowledged; dispatched at opcode 1 in a TCAP Begin
EventReportBCSMhandle_event_report_bcsm/1BCSM events (oAnswer, oDisconnect, …); drives CGrateS update/terminate
Continuehandle_continue/1Acknowledged
ConnectToResourcehandle_connect_to_resource/1Acknowledged
RequestReportBCSMEventhandle_request_report_bcsm_event/1Acknowledged
ApplyCharginghandle_apply_charging/1Parameters BER-decoded and acknowledged
Connecthandle_connect/1Parameters BER-decoded and acknowledged
ReleaseCallhandle_release_call/1Acknowledged

Unhandled opcodes are answered with a TCAP error (Facility Not Supported / Unexpected Data Value).

Outgoing Operations (gsmSCF → gsmSSF)

Generated by cap_request_generator.ex and sent via CapClient. The opcodes below are the values the generator emits:

OperationOpcodeGeneratorSender
InitialDP0CapRequestGenerator.initial_dp_request/3CapClient.initial_dp/3
Connect20CapRequestGenerator.connect_request/2CapClient.connect/3
ReleaseCall22CapRequestGenerator.release_call_request/2CapClient.release_call/3
RequestReportBCSMEvent23CapRequestGenerator.request_report_bcsm_event_request/2
Continue31CapRequestGenerator.continue_request/1CapClient.continue/2
ApplyCharging35CapRequestGenerator.apply_charging_request/3CapClient.apply_charging/4
InitialDPSMS60CapRequestGenerator.initial_dp_sms_request/5
NoteMM-Event89 (MAP)CapRequestGenerator.note_mm_event_request/4

InitialDPSMS (opcode 60) is for MO-SMS CAMEL control: sent by the smsSSF to the gsmSCF when an SMS-CSI / mo-sms-CSI is armed, before the short message is relayed to the SMSC. The arg is encoded with the generated CAP ASN.1 module and the dialogue carries the id-ac-cap3-sms-AC application context.

NoteMM-Event is a MAP operation (opcode 89, not CAP) used for CAMEL M-CSI mobility notifications from the VLR to the gsmSCF. It is encoded with the MAP ASN.1 module (:TCAPMessages.encode(:MapSpecificPDUs, …)) and carries the mm-EventReporting-v3 application context.

All CAP TCAP messages are encoded with :GenericTCAP.encode(:GenericPDUs, …). Only the MAP-based NoteMM-Event uses :TCAPMessages.


Web UI Features

CAMEL Sessions Page

Title: CAMEL Sessions  ·  Route: /camel_sessions (HTTPS, port 8087)

Real-time monitoring of active CAMEL call sessions:

  • Live session list with auto-refresh
  • Session details - OTID, Call ID, State, Duration
  • CAP Version detected from InitialDP and stored per session
  • Call information - IMSI, A-number, B-number, Service Key
  • State tracking - initiated, answered, terminated

Table Columns: Call ID, State, Version, IMSI, Calling Number, Called Number, Service Key, Duration, Start Time, OTID

The same session data is available over the REST API at /camel-sessions (see Monitoring & Operations).

CAMEL Request Builder

Title: CAMEL Request Builder  ·  Route: /camel_request (HTTPS, port 8087)

Interactive tool for building and sending CAP requests for testing. See the dedicated CAMEL Request Builder Guide for full details.

Request types offered by the form: InitialDP, Connect, ReleaseCall, RequestReportBCSMEvent, ApplyCharging, Continue.

CAP version selector: the form has a per-request CAP version dropdown (v1/v2/v3/v4 with their OIDs). The selection temporarily overrides the configured default for that request and persists across form changes; the request history shows the version used in a CAP Ver column.

Advanced SCCP/M3UA options:

FieldDefaultNotes
Called Party GT68988415011Destination Global Title
Calling Party GT(configurable)Originating Global Title
Called SSN146gsmSSF
Calling SSN146gsmSSF
OPC5013Originating Point Code
DPC5011Destination Point Code

Integration with CGrateS

OmniSS7 charges calls through the CGrateS SessionS JSON-RPC API. CGrateS.SessionsClient posts to the configured cgrates_url and maps CAP operations to SessionS methods:

CAP triggerSessionS method
InitialDPSessionSv1.InitiateSession
EventReportBCSM (oAnswer)SessionSv1.UpdateSession
EventReportBCSM (oDisconnect)SessionSv1.TerminateSession

Call Lifecycle with Charging

1. Call Initiation (InitialDP)

When the MSC sends InitialDP, CAMELGW:

  1. Detects the CAP version from the dialogue portion (falls back to the configured default)
  2. Decodes the InitialDP parameters (IMSI, calling/called numbers, service key)
  3. Calls CGrateS SessionSv1.InitiateSession via CAMELGW.Backend.handle_initial_dp/1
  4. Reads MaxUsage from the response (allowed call duration in seconds)
  5. Stores the session in CAMELGW.SessionStore (ETS) keyed by OTID, including the CAP version and a call ID of the form CAMEL-<hex OTID>
  6. Responds to the MSC using the detected CAP version

The account on the SessionS event is the subscriber IMSI when present, otherwise the calling number. The event also carries Destination, ServiceKey, MSCAddress, CallingPartyNumber, CalledPartyNumber, and OriginID (the call ID).

2. Call Answer (EventReportBCSM - oAnswer)

On oAnswer, the backend looks up the session, sets its state to answered, and calls SessionSv1.UpdateSession with usage 0 to start the debit loop. If CGrateS fails, the call is not dropped — the backend logs the error and continues.

3. Call Termination (EventReportBCSM - oDisconnect)

On oDisconnect, the backend computes the total duration from the session start time, sets state to terminated, calls SessionSv1.TerminateSession with the final usage, and deletes the session from the store. CDRs are generated by CGrateS. The session is cleaned up even if the terminate call errors.

CDR Fields from CAMEL

CDRs are produced by CGrateS and typically include:

  • Account - IMSI (or calling number fallback)
  • Destination - Called party number
  • OriginID - Call identifier (CAMEL-<hex OTID>)
  • Usage - Total call duration (seconds)
  • IMSI, CallingPartyNumber, CalledPartyNumber
  • MSCAddress - Serving MSC
  • ServiceKey - CAMEL service key

Testing

Manual Testing with the Request Builder

  1. Open https://your-server:8087/camel_request
  2. Select InitialDP, set Service Key / Calling / Called numbers, optionally pick a CAP version, and send. Note the OTID generated.
  3. Open https://your-server:8087/camel_sessions to see the session in state initiated.
  4. Send EventReportBCSM with oAnswer to move the session to answered.
  5. Send ReleaseCall with cause 16 (Normal) to terminate.

Testing with a Real MSC

Configure CAMEL service on your MSC/VLR (Service Key, gsmSCF Global Title) so it triggers InitialDP toward OmniSS7. Example for a Huawei MSC:

ADD CAMELSERVICE:
SERVICEID=1,
SERVICEKEY=100,
GSMSCFADDR="55512341234", # CAMELGW Global Title
DEFAULTCALLHANDLING=CONTINUE;

ADD CAMELSUBSCRIBER:
IMSI="310150123456789",
SERVICEID=1,
TRIGGERTYPE=TERMCALL;

Monitor Logs

OmniSS7 emits structured JSON logs (one object per line via OmniLogger.JsonFormatter), so you can filter on metadata fields:

# Tail and filter CAP events by the map_event field
tail -f /var/log/omniss7/omniss7.log | jq 'select(.map_event | tostring | startswith("CAP:"))'

Monitoring & Operations

Prometheus Metrics

CAMELGW exposes metrics at http://localhost:8080/metrics.

CAP metrics:

  • cap_requests_total{operation} - Total CAP requests by operation. Label values are snake_case, e.g. initial_dp, connect, release_call, continue, apply_charging.
  • cap_request_errors_total{operation} - CAP request generation/send errors by operation.

MAP / API metrics:

  • map_requests_total{operation} - Total MAP requests by operation
  • map_pending_requests - Number of pending MAP TID waiters

M3UA STP metrics (if STP mode enabled):

  • m3ua_stp_routing_failures_total{reason} - Routing failures by reason
# All CAP request counters
curl http://localhost:8080/metrics | grep cap_requests_total

# InitialDP only (note snake_case label)
curl http://localhost:8080/metrics | grep 'cap_requests_total{operation="initial_dp"}'

Health Checks

# M3UA peer status (TLS API on port 8445)
curl -k https://localhost:8445/m3ua-status

# Active CAMEL sessions (returns session_count + per-session detail)
curl -k https://localhost:8445/camel-sessions

There is no /api/ocs-status, /api/events, or /api/camel/sessions/count endpoint. Session counts come from /camel-sessions.

Logging Configuration

Adjust the log level in config/runtime.exs:

config :logger, level: :info   # :debug | :info | :warning | :error

The formatter is set to structured JSON in config/config.exs:

config :logger, :default_formatter,
format: {OmniLogger.JsonFormatter, :format},
metadata: :all,
truncate: :infinity

Troubleshooting

Issue: No CAP messages received

Symptoms: Request Builder works, but the MSC never sends InitialDP.

Check:

  1. M3UA peer status: curl -k https://localhost:8445/m3ua-status
  2. MSC CAMEL service configuration (Service Key, gsmSCF address)
  3. SCCP routing (the gsmSCF Global Title must route to CAMELGW)
  4. Firewall rules (allow SCTP port 2905)

Issue: CGrateS errors

Symptoms: not_configured, http_error, or cgrates_error in logs.

Check:

  1. cgrates_enabled: true and cgrates_url point at a reachable JSON-RPC endpoint
  2. The account (IMSI or calling number) exists and has balance in CGrateS
  3. cgrates_tenant and cgrates_request_type match your CGrateS rating setup
  4. cgrates_timeout is large enough for your CGrateS latency

On a charging failure during a call, CAMELGW continues the call rather than dropping it; the error is logged.

Issue: Session not found

Symptoms: EventReportBCSM logs "Session not found".

Cause: OTID mismatch or the session was already terminated.

Check: Verify the OTID in logs and ensure the DTID/OTID correlate across the dialogue.

Issue: Decode errors

Symptoms: "Failed to decode InitialDP" in logs.

Cause: CAP version mismatch or malformed message.

Check: Confirm the CAP version configuration matches the MSC, and capture a PCAP for analysis:

tcpdump -i eth0 -w cap_trace.pcap sctp port 2905

Summary

The CAMEL Gateway mode enables OmniSS7 to act as a gsmSCF with:

  • CAP protocol support (v1/v2/v3/v4) with per-request version override
  • Real-time charging via the CGrateS SessionS JSON-RPC API
  • Call control operations (Connect, Release, Continue, ApplyCharging)
  • Session management in ETS, keyed by OTID
  • Interactive testing via the Web UI Request Builder
  • Live monitoring of active sessions (Web UI and /camel-sessions API)
  • CDR generation by CGrateS for billing and analytics

For more detail:


Product: OmniSS7 CAMEL Gateway Documentation Version: 1.1