Back to page

PJSIP Trunk & Gateway Bindings

Raw Markdown & AI/RAG Chunks
Raw Markdown Source 2492 chars
# PJSIP Trunk & Gateway Bindings

The core SIP connectivity framework for **Asterisk 2** operates on the modern **PJSIP stack**. This architecture handles inbound and outbound media negotiation across external carrier gateways, remote softphones, and Dinstar SIM arrays.

---

## Trunk Handshake & Signaling Topology

The diagram below maps out how incoming SIP communications flow across internal authentication and transport validation layers:

```mermaid
graph TD
    %% Ingress Client
    subgraph ExternalNetwork["External Edge Nodes"]
        SipClient["SIP softphone / Gateway<br/>(Initiates INVITE Packet)"]
    end

    %% PJSIP Pipeline tier
    subgraph PjsipTier["Asterisk PJSIP Transport Module"]
        PjsipTrans["res_pjsip.so Engine<br/>(Socket Listeners)"]
        AuthLayer["PJSIP Authenticator<br/>(Validates MD5 Secrets)"]
    end

    %% Internal Database proxies
    subgraph LogicLedger["EF Core Live Registry"]
        EndpointRow[("ps_endpoints DB Table<br/>(Defines AOR & Codecs)")]
    end

    %% Dialplan Target
    subgraph EngineTarget["Routing Execution"]
        DialplanCore["Asterisk Core Dialplan<br/>(stasis Application Router)"]
    end

    %% Vectors
    SipClient ==>|"Raw UDP/TCP Handshake"| PjsipTrans
    PjsipTrans ==>|"Resolve Transport"| AuthLayer
    AuthLayer ==>|"Database Validation Hash"| EndpointRow
    EndpointRow ==>|"Authorize Credentials"| DialplanCore

    %% Fully Styled CSS Tokens
    classDef clientToken fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef pjsipToken fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef dbToken fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef targetToken fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class ExternalNetwork,SipClient clientToken;
    class PjsipTier,PjsipTrans,AuthLayer pjsipToken;
    class LogicLedger,EndpointRow dbToken;
    class EngineTarget,DialplanCore targetToken;
```

---

## Technical PJSIP Modeling Guidelines

### 1. Endpoint Identity Isolation
Every device binding maps to distinct identifier rows inside configuration schemas. Shared endpoints are strictly forbidden to ensure session logging scripts record explicit audio legs accurately.

### 2. Zero-State NAT Traversal
Trunk configurations force connection symmetric formatting (`rewrite_contact=yes`) to route NAT media paths cleanly across restrictive hardware network setups.
AI Chunks (RAG) 3 chunks
Chunk #1 PJSIP Trunk & Gateway Bindings
# PJSIP Trunk & Gateway Bindings

The core SIP connectivity framework for **Asterisk 2** operates on the modern **PJSIP stack**. This architecture handles inbound and outbound media negotiation across external carrier gateways, remote softphones, and Dinstar SIM arrays.

---
Chunk #2 Trunk Handshake & Signaling Topology
## Trunk Handshake & Signaling Topology

The diagram below maps out how incoming SIP communications flow across internal authentication and transport validation layers:

```mermaid
graph TD
    %% Ingress Client
    subgraph ExternalNetwork["External Edge Nodes"]
        SipClient["SIP softphone / Gateway<br/>(Initiates INVITE Packet)"]
    end

    %% PJSIP Pipeline tier
    subgraph PjsipTier["Asterisk PJSIP Transport Module"]
        PjsipTrans["res_pjsip.so Engine<br/>(Socket Listeners)"]
        AuthLayer["PJSIP Authenticator<br/>(Validates MD5 Secrets)"]
    end

    %% Internal Database proxies
    subgraph LogicLedger["EF Core Live Registry"]
        EndpointRow[("ps_endpoints DB Table<br/>(Defines AOR & Codecs)")]
    end

    %% Dialplan Target
    subgraph EngineTarget["Routing Execution"]
        DialplanCore["Asterisk Core Dialplan<br/>(stasis Application Router)"]
    end

    %% Vectors
    SipClient ==>|"Raw UDP/TCP Handshake"| PjsipTrans
    PjsipTrans ==>|"Resolve Transport"| AuthLayer
    AuthLayer ==>|"Database Validation Hash"| EndpointRow
    EndpointRow ==>|"Authorize Credentials"| DialplanCore

    %% Fully Styled CSS Tokens
    classDef clientToken fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef pjsipToken fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef dbToken fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef targetToken fill:#065f46,stroke:#10b981,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class ExternalNetwork,SipClient clientToken;
    class PjsipTier,PjsipTrans,AuthLayer pjsipToken;
    class LogicLedger,EndpointRow dbToken;
    class EngineTarget,DialplanCore targetToken;
```

---
Chunk #3 Technical PJSIP Modeling Guidelines
## Technical PJSIP Modeling Guidelines

### 1. Endpoint Identity Isolation
Every device binding maps to distinct identifier rows inside configuration schemas. Shared endpoints are strictly forbidden to ensure session logging scripts record explicit audio legs accurately.

### 2. Zero-State NAT Traversal
Trunk configurations force connection symmetric formatting (`rewrite_contact=yes`) to route NAT media paths cleanly across restrictive hardware network setups.