Telecom

Asterisk PJSIP: SIP Detail (Latest Versions)

MYLINEHUB Team • 2026-02-10 • 10 min

Updated guide for modern Asterisk (PJSIP era): sip detail with real configs, common mistakes, and troubleshooting steps.

Asterisk PJSIP: SIP Detail (Latest Versions)

After understanding basic SIP concepts, the next step is to look deeper into how SIP actually behaves inside modern Asterisk (PJSIP).

Many real-world telecom problems are not caused by dialplan mistakes, but by incorrect SIP signaling, authentication mismatches, codec negotiation failures, or NAT-related media routing issues.

This article explains SIP in detail from a practical Asterisk debugging perspective so you can understand what truly happens during a call.

Full SIP Call Flow (Step-by-Step)

A normal outbound SIP call follows this simplified sequence:

  1. Caller sends INVITE to Asterisk
  2. Asterisk replies 100 Trying
  3. Destination replies 180 Ringing
  4. Destination answers with 200 OK (includes SDP)
  5. Caller confirms with ACK
  6. RTP audio begins flowing directly between endpoints
  7. When call ends → BYE is exchanged

If you understand this ladder, SIP debugging becomes predictable.

Inside the SIP INVITE Message

The INVITE contains critical headers:

  • From / To → caller and destination identity
  • Call-ID → unique identifier for the call
  • CSeq → sequence number for transactions
  • Via → routing path for responses
  • Contact → where replies should be sent
  • Authorization → credentials (after 401 challenge)

Understanding these headers helps diagnose routing and auth issues.

SDP Negotiation (Where Audio Is Decided)

SIP itself does not carry audio. Instead, the INVITE and 200 OK include an SDP block that defines:

  • Supported codecs (PCMU, PCMA, Opus, etc.)
  • RTP IP address and port
  • Encryption (SRTP/DTLS for WebRTC)
  • Packet timing and payload types

One-way audio usually means:

  • Wrong IP in SDP (NAT problem)
  • Firewall blocking RTP ports

SIP Authentication in Depth (401 → Authorization → Success)

SIP commonly uses Digest authentication.

  1. Client sends INVITE/REGISTER
  2. Asterisk replies 401 Unauthorized with nonce
  3. Client resends request with hashed credentials
  4. If correct → call proceeds

Continuous 401 responses indicate:

  • Wrong username/password
  • Endpoint mismatch in PJSIP
  • Provider sending from unexpected IP

PJSIP Object Model (Real Structure of SIP in Asterisk)

Unlike legacy chan_sip, PJSIP separates configuration:

  • endpoint → dialplan context, codecs, timers
  • auth → credentials
  • aor → contact/registration location
  • identify → IP matching for trunks

If a call reaches Asterisk but no endpoint matches, the call fails before dialplan execution.

Registration vs IP-Based Trunks

Registration-based

  • Asterisk sends REGISTER to provider
  • Provider sends inbound calls to registered contact

IP-based (no registration)

  • Provider sends calls directly from fixed IP
  • PJSIP identify must match that IP

Missing identify rule is a common inbound failure.

Codec Negotiation Failures

If both sides share no common codec:

  • Call may fail immediately
  • Or connect with no audio

Safe default codecs:

  • PCMU (G.711 u-law)
  • PCMA (G.711 A-law)

Opus is common for WebRTC, but trunks often require G.711.

DTMF Transport Modes in Detail

  • RFC4733 (recommended) → separate RTP events
  • SIP INFO → signaling message
  • Inband → tones inside audio stream

IVR failures usually trace back to mismatched DTMF modes.

NAT and SIP Signaling Problems

NAT affects SIP in two different layers:

  • Signaling NAT → wrong Contact/Via headers
  • Media NAT → wrong RTP IP/port in SDP

PJSIP common fixes:

  • external_signaling_address
  • external_media_address
  • local_net
  • rtp_symmetric, rewrite_contact

Useful SIP Debug Commands in Asterisk

asterisk -rvvv
pjsip set logger on
pjsip show endpoints
pjsip show registrations
pjsip show contacts

These commands reveal nearly all SIP-layer problems.

Most Common Real-World SIP Failures

Inbound call never reaches dialplan

  • Identify IP mismatch
  • Firewall blocking SIP port

Call connects but no audio

  • NAT/RTP port blocking
  • Wrong SDP IP

Authentication loops

  • Wrong credentials
  • Provider realm mismatch

Key Takeaway

SIP debugging becomes easy when you understand:

  • INVITE → 200 OK → ACK → RTP → BYE call flow
  • SDP decides media, not SIP alone
  • PJSIP separates endpoint/auth/aor/identify logic
  • NAT and codec mismatches cause most real problems

Mastering these SIP details turns Asterisk troubleshooting from guesswork into a predictable technical process.

Try it

Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.

💬 Try WhatsApp Bot ▶️ Watch CRM YouTube Demos
Tip: Comment “Try the bot” on our YouTube videos to see automation in action.
M
MYLINEHUB Team
Published: 2026-02-10
Quick feedback
Was this helpful? (Yes 0 • No 0)
Reaction

Comments (0)

Be the first to comment.