Introduction
SigtranStack is a carrier-grade C#/.NET 9 implementation of the complete SIGTRAN and SS7 protocol stack. It provides native Linux SCTP transport, all five SIGTRAN adaptation layers (M3UA, M2UA, M2PA, SUA, IUA), and the full SS7 upper layer suite (SCCP, TCAP, ISUP, MAP, CAP).
Key Features
- Native SCTP — Linux kernel SCTP via P/Invoke (no managed shims)
- Multi-homing — sctp_bindx for path redundancy
- All 5 adaptation layers — M3UA (RFC 4666), M2UA (RFC 3331), M2PA (RFC 4165), SUA (RFC 3868), IUA (RFC 4233)
- Complete SS7 stack — SCCP (Q.711-714), TCAP (Q.771-772), ISUP (Q.761-764), MAP (3GPP TS 29.002), CAP (3GPP TS 29.078)
- SMS Home Routing — SRI-SM interception, HLR query, IMSI mapping, MT-Forward relay
- Carrier-grade — ConcurrentDictionary stores, Interlocked counters, adaptive congestion control, per-peer rate limiting
- ASP/AS management — Override, Loadshare, Broadcast traffic modes with automatic failover
Architecture
MAP · CAP · ISUP (Application Layer)
TCAP (Transaction Capabilities)
SCCP (Signalling Connection Control Part)
M3UA · M2UA · M2PA · SUA · IUA (Adaptation)
SCTP Transport (Native Linux Kernel)
Stack Initialization Order
// 1. Transport
var transport = new SctpTransport(sctpConfig);
// 2. Adaptation layer (M3UA shown)
var m3ua = new M3uaLayer(m3uaConfig, transport, logger);
// 3. SCCP
var sccp = new SccpLayer(m3ua, loggerFactory);
// 4. TCAP
var tcap = new TcapLayer(sccp, SubsystemNumber.Msc, loggerFactory);
// 5. Application layer (MAP shown)
var map = new MapLayer(tcap, localAddress, loggerFactory);
Quick Start
Connect to a remote STP/SGP and send an SRI-SM query:
using SigtranStack.Configuration;
using SigtranStack.Transport;
using SigtranStack.M3UA;
using SigtranStack.SCCP;
using SigtranStack.TCAP;
using SigtranStack.MAP;
// Transport
var transport = new SctpTransport(new SctpConfig {
RemoteAddresses = ["10.0.0.1"], RemotePort = 2905,
LocalAddresses = ["10.0.0.2"], LocalPort = 2905,
PayloadProtocolId = PayloadProtocolIdentifier.M3UA,
});
// M3UA
var m3ua = new M3uaLayer(new M3uaConfig {
OperationMode = OperationMode.Asp,
AutoActivate = true,
DefaultRoutingContext = 100,
}, transport);
// SCCP + TCAP
var sccp = new SccpLayer(m3ua);
var tcap = new TcapLayer(sccp, SubsystemNumber.Msc);
// MAP
var localAddr = SccpAddress.FromGlobalTitle("441234000001", SubsystemNumber.Msc);
var map = new MapLayer(tcap, localAddr);
// Wire events
map.ResultReceived += (_, e) => {
var (imsi, msc, _) = SmsUtils.DecodeSriSmResult(e.Parameter);
Console.WriteLine($"IMSI={imsi}, MSC={msc}");
};
// Start stack and send SRI-SM
await m3ua.StartAsync();
var hlr = SccpAddress.FromGlobalTitle("441234000002", SubsystemNumber.Hlr);
await map.SendRoutingInfoForSmAsync(hlr, "919990206824", "441234000001");
SCTP Transport class
Native Linux kernel SCTP transport using P/Invoke. Supports one-to-one style sockets with multi-homing via sctp_bindx.
Constructor
new SctpTransport(SctpConfig config, ILogger? logger = null, int maxConcurrentSends = 64)
Properties
| Name | Type | Description |
TransportState | SctpTransportState | Current SCTP association state |
IsConnected | bool | True when in Established state |
LocalEndPoints | IReadOnlyList<IPEndPoint> | Local multi-homed endpoints |
RemoteEndPoints | IReadOnlyList<IPEndPoint> | Remote multi-homed endpoints |
Methods
| Signature | Description |
Task ConnectAsync(CancellationToken ct) | Establish SCTP association |
Task SendAsync(byte[] data, ushort streamId, uint ppid, CancellationToken ct) | Send data on stream with PPID |
Task ShutdownAsync(CancellationToken ct) | Graceful SHUTDOWN chunk |
Task AbortAsync(string? reason, CancellationToken ct) | Abort with SO_LINGER |
Events
| Event | Args | Description |
DataReceived | SctpDataReceivedEventArgs | Data received (Data, StreamId, PayloadProtocolId, Tsn) |
AssociationStateChanged | SctpAssociationEventArgs | State transition (State, Info) |
ErrorOccurred | SctpErrorEventArgs | Error (ErrorMessage, Exception) |
SCTP Listener class
Server-side SCTP listener for SGP operation. Accepts incoming associations from ASPs.
var listener = new SctpListener(config);
listener.ConnectionAccepted += (_, transport) => { /* handle new ASP */ };
listener.Start();
Multi-Association Transport class
Manages a pool of SCTP associations with configurable load distribution. Supports Round-Robin, Active-Standby, Least-Loaded, and Weighted distribution.
Constructor
new MultiAssociationTransport(ILoggerFactory? loggerFactory,
LoadDistribution distribution = LoadDistribution.RoundRobin)
Load Distribution Modes
| Mode | Behavior |
RoundRobin | Cycle sequentially through active associations |
ActiveStandby | First active only; failover on disconnect |
LeastLoaded | Pick association with fewest in-flight messages |
Weighted | Distribute based on per-association Weight config |
Key Methods
| Signature | Description |
SctpAssociation AddAssociation(SctpAssociationConfig config) | Add single association to pool |
List<SctpAssociation> AddAssociations(int count, string remoteAddr, int port, ...) | Bulk add associations |
Task ConnectAllAsync(CancellationToken ct) | Connect all associations in parallel |
Task SendAsync(byte[] data, ushort streamId, uint ppid, CancellationToken ct) | Load-distributed send |
List<AssociationStatus> GetAllStatus() | Snapshot of all associations |
SCTP Configuration class
SctpConfig holds all SCTP socket parameters per RFC 4960.
| Property | Default | Description |
RemoteAddresses | — | Remote host addresses (multi-homing) |
RemotePort | 2905 | Remote SCTP port |
LocalAddresses | — | Local bind addresses |
LocalPort | 0 | Local port (0 = ephemeral) |
RtoInitialMs | 3000 | Initial RTO (retransmission timeout) |
RtoMinMs / RtoMaxMs | 1000 / 60000 | RTO bounds |
MaxRetransmits | 10 | Association max retransmits |
HeartbeatIntervalMs | 30000 | Heartbeat interval |
NumOutboundStreams | 10 | Number of outbound streams |
NumInboundStreams | 10 | Number of inbound streams |
PayloadProtocolId | M3UA (3) | PPID for outbound data |
M3UA Layer class
MTP3 User Adaptation Layer per RFC 4666. Handles ASP state machine (Down → Inactive → Active), heartbeats, protocol data transfer, and signalling network management (SSNM).
Constructor
new M3uaLayer(M3uaConfig config, ISctpTransport transport, ILogger? logger = null)
Configuration (M3uaConfig)
| Property | Default | Description |
OperationMode | Asp | Asp, Sgp, or Ipsp |
AutoActivate | true | Auto-send ASP Active after ASP Up Ack |
TrafficMode | Override | Override, Loadshare, or Broadcast |
AspIdentifier | — | Optional ASP identifier |
DefaultRoutingContext | — | Routing context for traffic |
PointCodeFormat | ITU_National | Point code format (ITU 14-bit, ANSI 24-bit) |
RoutingKeys | [] | List of M3uaRoutingKeyConfig entries |
Methods
| Signature | Description |
Task StartAsync(CancellationToken ct) | Connect SCTP and begin ASP Up handshake |
Task StopAsync(CancellationToken ct) | Graceful shutdown (ASP Down) |
Task SendProtocolDataAsync(uint dpc, uint opc, byte si, byte ni, byte sls, byte[] data, ...) | Send MTP3 user data (e.g. SCCP) |
Events
| Event | Description |
StateChanged | ASP state transition (OldState, NewState, Reason) |
DataReceived | Incoming protocol data (OPC, DPC, SI, NI, SLS, Data) |
ManagementNotification | SSNM events: DUNA, DAVA, SCON, DUPU |
M2UA Layer class
MTP2 User Adaptation per RFC 3331. Provides MTP2 backhauling over IP for signalling links.
new M2uaLayer(M2uaConfig config, ISctpTransport transport, ILogger? logger)
Events: LinkEstablished, LinkReleased, LinkStateChanged
M2PA Layer class
MTP2 Peer-to-Peer Adaptation per RFC 4165. Peer-to-peer MTP2 replacement with proving timers (T1, T2, T3, T4/T4E) per Q.703.
new M2paLayer(M2paConfig config, ISctpTransport transport, ILogger? logger)
SUA Layer class
SCCP User Adaptation per RFC 3868. Provides both connectionless and connection-oriented SCCP services over SCTP.
new SuaLayer(SuaConfig config, ISctpTransport transport, ILogger? logger)
IUA Layer class
ISDN User Adaptation per RFC 4233. Transports Q.921 LAPD frames over SCTP. Supports BRI/PRI interfaces and multiple ISDN variants (EuroISDN, ITU-T, DMS-100, 5ESS, NTT INS-Net).
new IuaLayer(IuaConfig config, ISctpTransport transport, ILogger? logger)
ASP Manager class
Manages Application Servers and their ASPs with traffic distribution per RFC 4666.
Traffic Modes
| Mode | Description |
Override | 1:1 — one active ASP per AS; automatic failover |
Loadshare | N:N — traffic distributed by SLS-based weighted round-robin |
Broadcast | 1:N — all active ASPs receive all traffic |
Key Methods
| Signature | Description |
void RegisterApplicationServer(ApplicationServer server) | Register a new AS |
void RegisterAsp(uint routingContext, AspInstance asp) | Add ASP to an AS |
void TransitionAspState(uint rc, uint aspId, AspState newState) | Change ASP state (triggers AS state recalculation) |
IReadOnlyList<AspInstance> SelectAspsForTraffic(uint rc) | Select ASPs for message delivery |
AspInstance? SelectAspBySls(uint rc, byte sls) | Select ASP by Signalling Link Selection |
SCCP Layer class
Signalling Connection Control Part per ITU-T Q.711-Q.714. Provides connectionless (UDT/XUDT) and connection-oriented (CR/CC/DT1) services with Global Title Translation (GTT).
Constructor
new SccpLayer(M3uaLayer? m3ua, ILoggerFactory? loggerFactory = null)
Properties
| Property | Default | Description |
LocalPointCode | — | Local signalling point code |
DefaultHopCounter | 15 | XUDT hop counter |
Gtt | — | Global Title Translator (add/remove GTT rules) |
MaxConnections | 10000 | Max concurrent SCCP connections |
Methods
| Signature | Description |
void RegisterSubsystem(byte ssn, ISccpUser user) | Register a local subsystem (TCAP, ISUP, etc.) |
Task SendUnitDataAsync(SccpAddress cdPA, SccpAddress cgPA, byte[] data, ...) | Send connectionless UDT |
Task SendExtendedUnitDataAsync(SccpAddress cdPA, SccpAddress cgPA, byte[] data, ...) | Send XUDT with hop counter |
Task<uint> ConnectAsync(SccpAddress cdPA, SccpAddress cgPA, ...) | Open connection-oriented session |
Task SendConnectionDataAsync(uint localRef, byte[] data) | Send data on connection |
Task ReleaseConnectionAsync(uint localRef, SccpReleaseCause cause) | Release connection |
GTT (Global Title Translation)
sccp.Gtt.AddRule(new GttRule {
Name = "HLR",
DigitPattern = "44123", // Match GT prefix
TranslationType = 0,
DestinationPointCode = 2,
DestinationSsn = SubsystemNumber.Hlr,
RouteOnDpcSsn = true,
Priority = 100,
});
SCCP Addressing class
SccpAddress represents an SCCP Called/Calling Party Address with optional Point Code, SSN, and Global Title.
Factory Methods
// Route on DPC + SSN
var addr = SccpAddress.FromDpcSsn(pointCode: 2, ssn: SubsystemNumber.Hlr);
// Route on Global Title
var addr = SccpAddress.FromGlobalTitle(
digits: "441234567890",
ssn: SubsystemNumber.Msc,
nai: NatureOfAddress.InternationalNumber,
np: NumberingPlan.IsdnTelephony);
Subsystem Numbers
| Constant | Value | Description |
SubsystemNumber.Hlr | 6 | Home Location Register |
SubsystemNumber.Vlr | 7 | Visitor Location Register |
SubsystemNumber.Msc | 8 | Mobile Switching Centre / SMSC |
SubsystemNumber.Map | 5 | MAP subsystem |
SubsystemNumber.Cap | 146 | CAMEL Application Part |
SubsystemNumber.Isup | 3 | ISDN User Part |
TCAP Layer class
Transaction Capabilities Application Part per ITU-T Q.771-Q.772. Manages structured dialogues (Begin/Continue/End) with invoke-level timeout tracking.
Constructor
new TcapLayer(SccpLayer? sccp, byte ssn, ILoggerFactory? loggerFactory = null)
Properties
| Property | Default | Description |
Ssn | — | SCCP subsystem number this TCAP is registered on |
DefaultInvokeTimeoutMs | 30000 | Default timeout for invokes |
MaxTransactions | 100000 | Max concurrent transactions |
TransactionIdleTimeoutMs | 300000 | Idle transaction cleanup timeout |
ActiveTransactionCount | — | Current number of active transactions |
Methods
| Signature | Description |
Task<uint> BeginDialogueAsync(SccpAddress cdPA, SccpAddress cgPA, List<TcapComponent>? components, byte[]? dialoguePortion) | Begin new TCAP dialogue (returns local TID) |
Task ContinueDialogueAsync(uint localTid, List<TcapComponent>? components, byte[]? dialoguePortion) | Continue existing dialogue |
Task EndDialogueAsync(uint localTid, List<TcapComponent>? components, byte[]? dialoguePortion) | End dialogue |
Task AbortDialogueAsync(uint localTid, TcapAbortCause? cause) | Abort dialogue |
TcapTransaction? FindTransaction(uint localTid) | Lookup transaction by ID |
Events
| Event | Description |
DialogueIndication | New incoming dialogue (Begin received) |
InvokeIndication | Invoke component received |
ResultIndication | ReturnResult component received |
ErrorIndication | ReturnError component received |
RejectIndication | Reject component received |
DialogueClose | Dialogue ended or aborted |
TCAP Component Types
// Invoke
var invoke = new TcapInvoke {
InvokeId = 1, OperationCode = 45, // SRI-SM
Parameter = encodedArg, TimeoutMs = 10000,
};
// Return Result
var result = new TcapReturnResult {
InvokeId = 1, OperationCode = 45,
Parameter = encodedResult, IsLast = true,
};
// Return Error
var error = new TcapReturnError {
InvokeId = 1, ErrorCode = 34,
};
ASN.1 BER Utilities static
Asn1Ber provides BER encoding/decoding primitives used throughout the stack.
| Method | Description |
byte[] EncodeTlv(byte tag, byte[] value) | Encode single-byte tag TLV |
byte[] EncodeTlv(byte tag1, byte tag2, byte[] value) | Encode two-byte tag TLV (high tag number form) |
byte[] EncodeLength(int length) | Encode BER definite length |
(int, int) DecodeLength(byte[] data, int offset) | Decode BER length (value, bytes consumed) |
(byte, int, int, int) ParseTlv(byte[] data, int offset) | Parse TLV: (Tag, ValueOffset, ValueLength, TotalLength) |
byte[] EncodeInteger(long value) | Encode BER INTEGER |
long DecodeInteger(byte[] data, int offset, int length) | Decode BER INTEGER |
MAP Layer class
GSM Mobile Application Part per 3GPP TS 29.002. Provides dialogue management, operation encoding, and high-level service methods for all MAP operations.
Constructor
new MapLayer(TcapLayer tcap, SccpAddress localAddress, ILoggerFactory? loggerFactory = null)
Properties
| Property | Default | Description |
MaxDialogues | 100000 | Max concurrent MAP dialogues |
DefaultInvokeTimeoutMs | 30000 | Default invoke timeout |
SriSmTimeoutMs | 10000 | SRI-SM specific timeout |
MtForwardSmTimeoutMs | 15000 | MT-ForwardSM timeout |
MoForwardSmTimeoutMs | 15000 | MO-ForwardSM timeout |
AlertScTimeoutMs | 10000 | AlertServiceCentre timeout |
UssdTimeoutMs | 30000 | USSD operation timeout |
ActiveDialogueCount | — | Current active dialogues |
Events
| Event | Args Type | Description |
OperationReceived | MapOperationEventArgs | Incoming MAP operation (DialogueId, InvokeId, OperationCode, Parameter, UserState) |
ResultReceived | MapResultEventArgs | Operation result received |
ErrorReceived | MapErrorEventArgs | MAP error received (ErrorCode, Parameter) |
TimeoutReceived | MapTimeoutEventArgs | Invoke timeout (TimeoutMs) |
DialogueOpened | MapDialogueEventArgs | New dialogue opened by remote |
DialogueClosed | MapDialogueEventArgs | Dialogue closed |
MAP Service Methods
High-level async methods that build parameters, open dialogues, and send MAP operations. All return the dialogue ID (uint) for correlation.
| Method | Description |
SendRoutingInfoForSmAsync(hlrAddr, msisdn, scAddr, userState?) | SRI-SM — query HLR for subscriber routing info |
MtForwardSmAsync(mscAddr, imsi, smscAddr, tpdu, userState?) | MT-ForwardSM — deliver SMS to MSC |
MoForwardSmAsync(smscAddr, smscGt, senderMsisdn, tpdu, userState?) | MO-ForwardSM — submit SMS from subscriber |
ReportSmDeliveryStatusAsync(hlrAddr, msisdn, scAddr, outcome, userState?) | Report SMS delivery status to HLR |
AlertServiceCentreAsync(smscAddr, msisdn, scAddr, userState?) | Alert SMSC that subscriber is reachable |
UpdateLocationAsync(hlrAddr, imsi, mscNumber, vlrNumber, userState?) | Update subscriber location at HLR |
SendAuthenticationInfoAsync(hlrAddr, imsi, numVectors, userState?) | Request authentication vectors |
SendRoutingInfoAsync(hlrAddr, msisdn, gmscAddr?, userState?) | SRI — routing info for voice call |
ProcessUssdRequestAsync(hlrAddr, ussdString, msisdn?, userState?) | USSD request (e.g. *123#) |
AnyTimeInterrogationAsync(hlrAddr, msisdn, gsmScfAddr, userState?) | ATI — query subscriber location/state |
CheckImeiAsync(eirAddr, imei, userState?) | Check IMEI against EIR |
Responding to Incoming Operations
map.OperationReceived += async (_, e) => {
if (e.OperationCode == MapOperationCode.SendRoutingInfoForSM) {
var (msisdn, _, _) = SmsUtils.DecodeSriSmArg(e.Parameter);
var result = SmsUtils.BuildSriSmResult(imsi, mscAddress);
await map.SendResultAndCloseAsync(
e.DialogueId, e.InvokeId,
MapOperationCode.SendRoutingInfoForSM, result);
}
};
SMS Utilities static
SmsUtils provides encoding and decoding for SMS TPDUs, MAP SMS parameters, and GSM 7-bit packing.
SRI-SM (Send Routing Info for SM)
| Method | Description |
(string? Msisdn, bool SmRpPri, string? ScAddress) DecodeSriSmArg(byte[] data) | Decode SRI-SM argument |
(string? Imsi, string? MscAddress, string? Lmsi) DecodeSriSmResult(byte[] data) | Decode SRI-SM result |
byte[] BuildSriSmResult(string imsi, string mscAddress) | Build SRI-SM result (for responding) |
SMS TPDU Building
| Method | Description |
byte[] BuildSmsDeliverTpdu(string originator, string text) | Build SMS-DELIVER TPDU (MT direction) |
byte[] BuildSmsSubmitTpdu(string destination, string text) | Build SMS-SUBMIT TPDU (MO direction) |
List<byte[]> BuildConcatenatedSmsDeliverTpdus(string originator, string text) | Build multi-part SMS with UDH concatenation |
SMS TPDU Decoding
| Method | Description |
(string? Text, string? Originator, byte Dcs) DecodeSmsDeliverTpdu(byte[] tpdu) | Decode SMS-DELIVER |
(string? Text, string? DestNumber, byte Dcs) DecodeSmsSubmitTpdu(byte[] tpdu) | Decode SMS-SUBMIT |
MT/MO ForwardSM
| Method | Description |
(string?, string?, byte[]?) DecodeMtForwardSmArg(byte[] data) | Decode MT-ForwardSM (IMSI, SMSC, TPDU) |
(string?, string?, byte[]?) DecodeMoForwardSmArg(byte[] data) | Decode MO-ForwardSM (DestAddr, SenderMsisdn, TPDU) |
Other
| Method | Description |
(string?, string?) DecodeAlertServiceCentreArg(byte[] data) | Decode AlertServiceCentre (Msisdn, ScAddress) |
string GetMapErrorName(int errorCode) | Human-readable MAP error name |
byte[] PackGsm7Bit(string text) | Pack text in GSM 7-bit encoding |
bool NeedsUcs2(string text) | Check if text requires UCS-2 |
SMS Home Router class
Intercepts SRI-SM requests, queries the HLR for real subscriber data, stores IMSI-to-MSC mappings, and relays MT-Forward-SM to the real MSC. Provides carrier-grade SMS home routing with congestion control and retry logic.
Architecture
Foreign SMSC ──SRI-SM──> [Home Router] ──SRI-SM──> HLR
│
stores IMSI→MSC mapping
returns local MSC address
│
Foreign SMSC ──MT-FSM──> [Home Router] ──MT-FSM──> Real MSC
Configuration
var config = new SmsHomeRouterConfig {
LocalMscAddress = "441234000001",
HlrAddress = SccpAddress.FromGlobalTitle("441234000002", 6),
MappingTtl = TimeSpan.FromMinutes(5),
MaxStoredMappings = 500_000,
HlrQueryTimeoutMs = 10_000,
MtForwardTimeoutMs = 15_000,
MaxRetries = 2,
RetryDelayMs = 500,
HomeImsiPrefixes = new HashSet<string> { "23415", "23410" },
RemoveMappingOnDelivery = false,
Enabled = true,
};
Usage
var hr = new SmsHomeRouter(mapLayer, config, congestionController, loggerFactory);
hr.SriSmInterceptedEvent += (_, e) =>
Console.WriteLine($"Intercepted: MSISDN={e.Msisdn} IMSI={e.Imsi}");
hr.Start();
// Query stats
var stats = hr.GetStats();
Console.WriteLine($"Intercepted: {stats.SriSmIntercepted}, Active: {stats.MappingsActive}");
// Lookup a mapping
var entry = hr.LookupMapping("234150123456789");
// Shutdown
hr.Stop();
hr.Dispose();
Public API
| Method / Property | Description |
void Start() | Start intercepting SRI-SM and MT-Forward operations |
void Stop() | Stop and cancel pending operations |
bool IsRunning | Whether the home router is active |
int ActiveMappings | Count of stored IMSI mappings |
SmsHomeRouterStats GetStats() | Snapshot of all counters |
void ResetStats() | Reset all counters to zero |
ImsiMappingEntry? LookupMapping(string imsi) | Lookup mapping by IMSI |
int PurgeMappings() | Remove all mappings |
int PurgeExpiredMappings() | Remove expired mappings only |
Events
| Event | Description |
SriSmInterceptedEvent | SRI-SM successfully intercepted (MSISDN, IMSI, MscAddress) |
MtForwardRelayedEvent | MT-Forward-SM relayed to real MSC |
OperationFailedEvent | Any operation failure (with detail string) |
ISUP Layer class
ISDN User Part per ITU-T Q.761-Q.764. Manages circuit-switched call setup/release with timer supervision.
Constructor
new IsupLayer(M3uaLayer? m3ua, ILoggerFactory? loggerFactory = null)
Call Control Methods
| Method | Description |
Task<ushort> SetupCallAsync(PointCode destPc, IsupNumber called, IsupNumber? calling, byte category) | Initiate call (sends IAM), returns CIC |
Task SendAcmAsync(ushort cic, ushort bci) | Send Address Complete (ACM) |
Task SendAnmAsync(ushort cic) | Send Answer (ANM) |
Task ReleaseCallAsync(ushort cic, byte causeValue) | Release call (sends REL) |
Task BlockCircuitAsync(ushort cic) | Block circuit (BLO) |
Task UnblockCircuitAsync(ushort cic) | Unblock circuit (UBL) |
Task ResetCircuitAsync(ushort cic) | Reset circuit (RSC) |
Events
| Event | Description |
IncomingCall | IAM received (CIC, CalledNumber, CallingNumber) |
CallAlerting | ACM received (ringing) |
CallConnected | ANM received (answered) |
CallReleased | REL/RLC received (with Q.850 cause) |
ISUP Number Encoding
var called = new IsupNumber {
Digits = "441234567890",
NatureOfAddress = 0x04, // International
NumberingPlan = 0x01, // ISDN/E.164
};
byte[] encoded = called.EncodeCalledParty();
CAP / CAMEL Layer class
CAMEL Application Part per 3GPP TS 29.078. Supports CAMEL Phase 1-4 for call control, SMS control, and GPRS control from Service Control Functions (SCF).
Constructor
new CapLayer(TcapLayer tcap, SccpAddress localAddress,
CapLayerConfig? config = null, ILoggerFactory? loggerFactory = null)
Call Control Methods (gsmSCF → gsmSSF)
| Method | Description |
InitialDPAsync(scfAddr, serviceKey, calledParty, callingParty?, imsi?, userState?) | Initial Detection Point |
SendConnectAsync(dialogueId, destinationRoutingAddress) | Connect to destination |
SendContinueAsync(dialogueId) | Continue call processing |
SendReleaseCallAsync(dialogueId, causeValue) | Release call (Q.850 cause) |
SendRequestReportBCSMEventAsync(dialogueId, events...) | Request BCSM event reports |
SendApplyChargingAsync(dialogueId, maxDuration, releaseIfExceeded, leg) | Apply charging |
SendActivityTestAsync(dialogueId) | Activity test (keepalive) |
SendResetTimerAsync(dialogueId, timerValue) | Reset TSSF timer |
SMS Control Methods
| Method | Description |
InitialDPSMSAsync(scfAddr, serviceKey, calledParty, ...) | Initial DP for SMS |
SendConnectSMSAsync(dialogueId, destAddr?, smscAddr?) | Connect SMS to destination |
SendContinueSMSAsync(dialogueId) | Continue SMS processing |
SendReleaseSMSAsync(dialogueId, rpCause) | Release SMS (RP cause) |
BCSM Event Types
| Event | Value | Description |
CollectedInfo | 2 | Digits collected |
RouteSelectFailure | 4 | Route selection failed |
OAnswer | 7 | Originating side answered |
ODisconnect | 9 | Originating side disconnected |
TAnswer | 15 | Terminating side answered |
TDisconnect | 17 | Terminating side disconnected |
Application Contexts
| Context | Phase |
CapApplicationContext.GsmSsfToScf_v1 | CAMEL Phase 1 |
CapApplicationContext.GsmSsfToScf_v2 | CAMEL Phase 2 |
CapApplicationContext.GsmSsfToScf_v3 | CAMEL Phase 3 (UMTS) |
CapApplicationContext.GsmSsfToScf_v4 | CAMEL Phase 4 (Enhanced) |
CapApplicationContext.GsmSsfToScfSms_v3 | SMS CAMEL Phase 3 |
CapApplicationContext.GprsSsfToScf_v3 | GPRS CAMEL Phase 3 |
Congestion Controller class
Adaptive sliding-window congestion controller with rate control. Adjusts window size and inter-send delay based on success/failure/timeout signals.
Constructor
new CongestionController(
maxConcurrent: 50,
minConcurrent: 5,
initialDelayMs: 50,
minDelayMs: 10,
maxDelayMs: 2000)
Usage Pattern
if (await cc.AcquireSlot(ct)) {
try {
await SendOperation();
cc.OnSuccess();
} catch (TimeoutException) {
cc.OnTimeout();
} catch {
cc.OnError();
} finally {
cc.ReleaseSlot();
}
}
Signal Methods
| Method | Effect |
OnSuccess() | Count toward recovery; widen window after threshold |
OnCongestion(string reason) | Halve window, increase delay |
OnTimeout() | Decrease window, increase delay |
OnError() | Count error (no window change) |
Task<bool> AcquireSlot(CancellationToken ct) | Wait for available slot in window |
void ReleaseSlot() | Return slot after response |
CongestionSnapshot GetSnapshot() | Immutable state snapshot |
Rate Limiter class
Token bucket rate limiter for inbound message protection.
TokenBucketRateLimiter
var limiter = new TokenBucketRateLimiter(maxTokens: 1000, refillPerSecond: 100.0);
if (limiter.TryConsume()) { /* process message */ }
PerPeerRateLimiter
var limiter = new PerPeerRateLimiter(maxTokensPerPeer: 100, refillPerSecond: 50.0);
if (limiter.TryConsume(peerId: originatingPointCode)) { /* allow */ }
Point Code class
SS7 Point Code supporting ITU (14-bit: 3-8-3) and ANSI (24-bit: 8-8-8) formats.
Factory Methods
var itu = PointCode.CreateItuInternational(zone: 3, area: 8, spId: 3);
var nat = PointCode.CreateItuNational(1234);
var ansi = PointCode.CreateAnsi(network: 10, cluster: 20, member: 30);
var generic = PointCode.FromValue(1234, PointCodeFormat.ITU_National);
SIGTRAN Message class
Common SIGTRAN message format (8-byte header + TLV parameters) per RFC 4666 Section 3.1. Used by all adaptation layers.
var msg = new SigtranMessage(MessageClass.Transfer, M3uaMessageType.DATA);
msg.AddParameter(new TlvParameter(ParameterTag.ProtocolData, protocolData));
byte[] wire = msg.Encode();
// Decode
var decoded = SigtranMessage.Decode(wire);
var pd = decoded.FindParameter(ParameterTag.ProtocolData);
Enumerations Reference
AspState
Down | Inactive | Active | PendingActive | PendingInactive | PendingDown |
OperationMode
Asp — Application Server Process | Sgp — Signalling Gateway Process | Ipsp — IP Signalling Point (peer-to-peer) |
TrafficMode
Override (1) — 1:1 failover | Loadshare (2) — N:N distributed | Broadcast (3) — 1:N replicated |
ServiceIndicator
SNM (0) | SCCP (3) | TUP (4) | ISUP (5) |
NetworkIndicator
International (0) | National (2) |
PointCodeFormat
ITU_International — 3-8-3 (14-bit) | ITU_National — 14-bit | ANSI — 8-8-8 (24-bit) |
Constants Reference
Payload Protocol Identifiers
| Protocol | PPID |
| IUA | 1 |
| M2UA | 2 |
| M3UA | 3 |
| SUA | 4 |
| M2PA | 5 |
Default SCTP Ports
| Protocol | Port |
| M3UA | 2905 |
| M2UA | 2904 |
| M2PA | 3565 |
| SUA | 14001 |
| IUA | 9900 |
MAP Operation Codes
| Operation | Code |
| UpdateLocation | 2 |
| CancelLocation | 3 |
| SendRoutingInfo | 22 |
| SendRoutingInfoForSM | 45 |
| MoForwardSM | 46 |
| MtForwardSM | 44 |
| ReportSMDeliveryStatus | 47 |
| SendAuthenticationInfo | 56 |
| ProcessUnstructuredSSRequest | 59 |
| AlertServiceCentre | 64 |
| AnyTimeInterrogation | 71 |
CAP Operation Codes
| Operation | Code |
| InitialDP | 0 |
| Connect | 20 |
| ReleaseCall | 22 |
| RequestReportBCSMEvent | 23 |
| EventReportBCSM | 24 |
| Continue | 31 |
| ApplyCharging | 35 |
| ApplyChargingReport | 36 |
| ActivityTest | 55 |
| InitialDPSMS | 60 |
| ConnectSMS | 62 |
| ContinueSMS | 65 |
| ReleaseSMS | 66 |
Q.850 Cause Values
| Cause | Value |
| UnallocatedNumber | 1 |
| NormalCallClearing | 16 |
| UserBusy | 17 |
| NoAnswerFromUser | 19 |
| CallRejected | 21 |
| TemporaryFailure | 41 |
| NormalUnspecified | 31 |
Almuqeet Sigtran Stack Documentation
RFC references: 4960 (SCTP), 4666 (M3UA), 3331 (M2UA), 4165 (M2PA), 3868 (SUA), 4233 (IUA)
ITU-T: Q.711-714 (SCCP), Q.771-772 (TCAP), Q.761-764 (ISUP), Q.850 (Causes)
3GPP: TS 29.002 (MAP), TS 29.078 (CAP), TS 23.040 (SMS)