Cannot get custom header

image
First image: I already setted custom header using SIPAddHeader
But when i received a call from outside number i print the header out but my custom header wasn’t there.

Can anyone tell me why and how to fix it

You’d need to show the actual console output, including SIP trace using “sip set debug on”.

This is my trace log when i use MicroSip (105@ my-server.com) call to MicroSip (106@ my-server.com) using context [from-outside3]

---
    -- Executing [888@from -outside3:2] SIPAddHeader("SIP/105-000000f4", "X-CallerID:<105>") in new stack
    -- Executing [888@from -outside3:3] NoOp("SIP/105-000000f4", "SIP Header:") in new stack
    -- Executing [888@from-outside3:4] Dial("SIP/105-000000f4", "SIP/106,,G(from-outside4,106,1)") in new stack
  == Using SIP RTP CoS mark 5
Audio is at 17756
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to xxxx:`Preformatted text`
INVITE sip:106@192.168.1.xxx;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.xxxx:5060;branch=z9hG4bK74f819aa;rport
Max-Forwards: 70
From: <sip:105@xxxxx>;tag=as113ba79c
To: <sip:106@xxxxx;ob>
Contact: <sip:105@xxxxx:5060>
Call-ID: 5fcf402d0b2d22d652b3d4f2694b481f@xxxxx:5060
CSeq: 102 INVITE
User-Agent: primas
Date: Wed, 05 Jul 2023 08:50:50 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
X-CallerID: <105>
Remote-Party-ID: "105" <sip:105@xxxx>;party=calling;privacy=off;screen=no
Content-Type: application/sdp
Content-Length: 265

v=0
o=root 1892084205 1892084205 IN IP4 xxxx
s=Asterisk PBX 18.14.0
c=IN IP4 xxxx
t=0 0
m=audio 4048 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=rtcp-mux
a=sendrecv

---
    -- Called SIP/106

<--- SIP read from UDP:xxxxx --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.120:5060;rport=5060;received=xxxx;branch=z9hG4bK74f819aa
Call-ID: 5fcf402d0b2d22d652b3d4f2694b481f@xxxxx:5060
From: <sip:105@xxxxx>;tag=as113ba79c
To: <sip:106@xxxx;ob>
CSeq: 102 INVITE
Content-Length: 0

<------------->
--- (7 headers 0 lines) ---

<--- SIP read from UDP:xxxxx--->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP xxxxx:5060;rport=5060;received=xxx;branch=z9hG4bK74f819aa
Call-ID: 5fcf402d0b2d22d652b3d4f2694b481f@xxxxx:5060
From: <sip:105@xxxxx>;tag=as113ba79c
To: <sip:106@xxxxx;ob>;tag=795abdfa421341ea9812ec8f46f2f640
CSeq: 102 INVITE
Contact: <sip:106@xxxxx;ob>
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
sip_route_dump: route/path hop: <sip:106@xxxxx;ob>
    -- SIP/106-000000f5 is ringing
Audio is at 13432
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to xxxxx:
INVITE sip:105@xxxxx;ob SIP/2.0
Via: SIP/2.0/UDP xxxx:5060;branch=z9hG4bK68981ad6;rport
Max-Forwards: 70
From: <sip:888@xxxx>;tag=as4c4afd3c
To: <sip:105@xxxx>;tag=a0418cccb282497a81032384b437986e
Contact: <sip:888@xxxx:5060>
Call-ID: 8807c0cc14914b05875f15f611b53cf1
CSeq: 102 INVITE
User-Agent: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
X-asterisk-Info: SIP re-invite (External RTP bridge)
Content-Type: application/sdp
Content-Length: 694

v=0
o=root 122981454 122981456 IN IP4 192.168.1.120
s=Asterisk PBX 18.14.0
c=IN IP4 192.168.1.120
t=0 0
m=audio 13432 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=ice-ufrag:0ca9846956a2979e6277823c790a5863
a=ice-pwd:1f3aa4f4341a09371b1d9aa11c9652f2
a=candidate:Hc0a80178 1 UDP 2130706431 xxxx 13432 typ host
a=candidate:Sea12eff 1 UDP 1694498815 14.161.46.255 58232 typ srflx raddr xxxx rport 13432
a=candidate:Hc0a80178 2 UDP 2130706430 xxxx 13433 typ host
a=candidate:Sea12eff 2 UDP 1694498814 14.161.46.255 58233 typ srflx raddr xxxx rport 13433
a=rtcp-mux
a=sendrecv

---

<--- SIP read from UDP:xxxxxx --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP xxxx:5060;rport=5060;received=xxxx;branch=z9hG4bK68981ad6
Call-ID: 8807c0cc14914b05875f15f611b53cf1
From: <sip:888@xxxx>;tag=as4c4afd3c
To: <sip:105@xxxx>;tag=a0418cccb282497a81032384b437986e
CSeq: 102 INVITE
Contact: <sip:105@xxxx;ob>
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub, trickle-ice
Content-Type: application/sdp
Content-Length: 320

v=0
o=- 3897561049 3897561051 IN IP4 192.168.1.153
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4048 RTP/AVP 0 101
c=IN IP4 192.168.1.153
b=TIAS:64000
a=rtcp:4049 IN IP4 192.168.10.233
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ssrc:1690572444 cname:687a104424866191
<------------->
--- (11 headers 15 lines) ---
Comparing SDP version 3897561050 -> 3897561051 and unique parts [- 3897561049 IN IP4 192.168.1.153] -> [- 3897561049 IN IP4 192.168.1.153]
Found RTP audio format 0
Found RTP audio format 101
Found audio description format PCMU for ID 0
Found audio description format telephone-event for ID 101
Capabilities: us - (opus|ulaw|alaw|gsm), peer - audio=(ulaw)/video=(nothing)/text=(nothing), combined - (ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 192.168.1.153:4048
Transmitting (NAT) to 192.168.1.153:61771:
ACK sip:105@192.168.1.153:61771;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.1.120:5060;branch=z9hG4bK40166037;rport
Max-Forwards: 70
From: <sip:888@192.168.1.120>;tag=as4c4afd3c
To: <sip:105@192.168.1.120>;tag=a0418cccb282497a81032384b437986e
Contact: <sip:888@192.168.1.120:5060>
Call-ID: 8807c0cc14914b05875f15f611b53cf1
CSeq: 102 ACK
User-Agent: primas
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
Sending to 192.168.1.119:5060 (NAT)
Looking for s in from-outside (domain 192.168.1.120)

<--- Transmitting (NAT) to 192.168.1.119:5060 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.1.119;branch=z9hG4bK5728.c1766e51000000000000000000000000.0;received=192.168.1.119;rport=5060
From: <sip:dispatcher@localhost>;tag=3393f0703fb0ccaca74109ff37de39f5-4823dbad
To: <sip:xxxxx:5060>;tag=as107a6ea2
Call-ID: 2b0af15f4717c487-52183@127.0.0.1
CSeq: 10 OPTIONS
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Accept: application/sdp
Content-Length: 0

<--- SIP read from UDP:xxxxxxx --->

<------------->

<--- SIP read from UDP:xxxxxxx --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP xxxx:5060;rport=5060;received=192.168.1.120;branch=z9hG4bK74f819aa
Call-ID: 5fcf402d0b2d22d652b3d4f2694b481f@192.168.1.120:5060
From: <sip:105@ xxx>;tag=as113ba79c
To: <sip:106@ xxxx;ob>;tag=795abdfa421341ea9812ec8f46f2f640
CSeq: 102 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Contact: <sip:106@xxxxxxxx;ob>
Supported: replaces, 100rel, timer, norefersub
Content-Type: application/sdp

> Blockquote

Content-Length: 320


===========================

If you need more information please let me know. Thank you for your support

That only shows the outgoing call leg. It does not show the incoming call leg that you are attempting to get the “X-CallerID” header from.

If what you are expecting is that you call “SIPAddHeader” and then use SIP_HEADER to get that information you just added, that won’t work because SIP_HEADER doesn’t do that.

---

<--- SIP read from UDP:192.168.1.153:61771 --->
INVITE sip:888@192.168.1.120 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPj15204b0d348148429902f155092342ed
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>
Contact: <sip:105@192.168.1.153:61771;ob>
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25391 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.21.3
Content-Type: application/sdp
Content-Length: 344

v=0
o=- 3897562385 3897562385 IN IP4 192.168.1.153
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4050 RTP/AVP 8 0 101
c=IN IP4 192.168.1.153
b=TIAS:64000
a=rtcp:4051 IN IP4 192.168.10.233
a=sendrecv
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ssrc:1086587744 cname:6984355309ae4e75
<------------->
--- (15 headers 16 lines) ---
Sending to 192.168.1.153:61771 (NAT)
Sending to 192.168.1.153:61771 (NAT)
Using INVITE request as basis request - eec5eee355ec46b6bf2f9740612851dd
Found peer '105' for '105' from 192.168.1.153:61771

<--- Reliably Transmitting (NAT) to 192.168.1.153:61771 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.153:61771;branch=z9hG4bKPj15204b0d348148429902f155092342ed;received=192.168.1.153;rport=61771
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as5cdf0602
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25391 INVITE
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="2b2f1f8f"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog 'eec5eee355ec46b6bf2f9740612851dd' in 32000 ms (Method: INVITE)

<--- SIP read from UDP:192.168.1.153:61771 --->
ACK sip:888@192.168.1.120 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPj15204b0d348148429902f155092342ed
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as5cdf0602
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25391 ACK
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---

<--- SIP read from UDP:192.168.1.153:61771 --->
INVITE sip:888@192.168.1.120 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPj7ec138a0b3654cf7b3ceb3ccdf45f62b
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>
Contact: <sip:105@192.168.1.153:61771;ob>
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25392 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: MicroSIP/3.21.3
Authorization: Digest username="105", realm="asterisk", nonce="2b2f1f8f", uri="sip:888@192.168.1.120", response="6ee9028c7b055b9d831231f0e1f845be", algorithm=MD5
Content-Type: application/sdp
Content-Length: 344

v=0
o=- 3897562385 3897562385 IN IP4 192.168.1.153
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4050 RTP/AVP 8 0 101
c=IN IP4 192.168.1.153
b=TIAS:64000
a=rtcp:4051 IN IP4 192.168.10.233
a=sendrecv
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ssrc:1086587744 cname:6984355309ae4e75
<------------->
--- (16 headers 16 lines) ---
Sending to 192.168.1.153:61771 (NAT)
Using INVITE request as basis request - eec5eee355ec46b6bf2f9740612851dd
Found peer '105' for '105' from 192.168.1.153:61771
  == Using SIP RTP CoS mark 5
Got SDP version 3897562385 and unique parts [- 3897562385 IN IP4 192.168.1.153]
Found RTP audio format 8
Found RTP audio format 0
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format PCMU for ID 0
Found audio description format telephone-event for ID 101
Capabilities: us - (opus|ulaw|alaw|gsm), peer - audio=(ulaw|alaw)/video=(nothing)/text=(nothing), combined - (ulaw|alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
       > 0x561aba8efce0 -- Strict RTP learning after remote address set to: 192.168.1.153:4050
Peer audio RTP is at port 192.168.1.153:4050
Looking for 888 in from-outside3 (domain 192.168.1.120)
sip_route_dump: route/path hop: <sip:105@192.168.1.153:61771;ob>

<--- Transmitting (NAT) to 192.168.1.153:61771 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.153:61771;branch=z9hG4bKPj7ec138a0b3654cf7b3ceb3ccdf45f62b;received=192.168.1.153;rport=61771
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25392 INVITE
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Contact: <sip:888@192.168.1.120:5060>
Content-Length: 0


<------------>
    -- Executing [888@from-outside3:1] Playback("SIP/105-000000f7", "/var/lib/asterisk/sounds/en/999/default") in new stack
Audio is at 17172
Adding codec ulaw to SDP
Adding codec alaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<--- Reliably Transmitting (NAT) to 192.168.1.153:61771 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.153:61771;branch=z9hG4bKPj7ec138a0b3654cf7b3ceb3ccdf45f62b;received=192.168.1.153;rport=61771
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25392 INVITE
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Contact: <sip:888@192.168.1.120:5060>
Content-Type: application/sdp
Content-Length: 718

v=0
o=root 509783810 509783810 IN IP4 192.168.1.120
s=Asterisk PBX 18.14.0
c=IN IP4 192.168.1.120
t=0 0
m=audio 17172 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=ice-ufrag:3712adae561b6c630805226c087e1393
a=ice-pwd:14afa3b619878c4d73e5865769c00741
a=candidate:Hc0a80178 1 UDP 2130706431 192.168.1.120 17172 typ host
a=candidate:Sea12eff 1 UDP 1694498815 14.161.46.255 61972 typ srflx raddr 192.168.1.120 rport 17172
a=candidate:Hc0a80178 2 UDP 2130706430 192.168.1.120 17173 typ host
a=candidate:Sea12eff 2 UDP 1694498814 14.161.46.255 61973 typ srflx raddr 192.168.1.120 rport 17173
a=rtcp-mux
a=sendrecv

<------------>

<--- SIP read from UDP:192.168.1.153:61771 --->
ACK sip:888@192.168.1.120:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPjce2bc1894f8741fea1b0aecd066d0abb
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25392 ACK
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---

<--- SIP read from UDP:192.168.1.153:61771 --->
INVITE sip:888@192.168.1.120:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPja185ea9bc5ac4f3db585edc554cbce36
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Contact: <sip:105@192.168.1.153:61771;ob>
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25393 INVITE
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
Content-Type: application/sdp
Content-Length: 320

v=0
o=- 3897562385 3897562386 IN IP4 192.168.1.153
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4050 RTP/AVP 0 101
c=IN IP4 192.168.1.153
b=TIAS:64000
a=rtcp:4051 IN IP4 192.168.10.233
a=ssrc:1086587744 cname:6984355309ae4e75
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
<------------->
--- (14 headers 15 lines) ---
Sending to 192.168.1.153:61771 (NAT)
Comparing SDP version 3897562385 -> 3897562386 and unique parts [- 3897562385 IN IP4 192.168.1.153] -> [- 3897562385 IN IP4 192.168.1.153]
Found RTP audio format 0
Found RTP audio format 101
Found audio description format PCMU for ID 0
Found audio description format telephone-event for ID 101
Capabilities: us - (opus|ulaw|alaw|gsm), peer - audio=(ulaw)/video=(nothing)/text=(nothing), combined - (ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
       > 0x561aba8efce0 -- Strict RTP learning after remote address set to: 192.168.1.153:4050
Peer audio RTP is at port 192.168.1.153:4050

<--- Transmitting (NAT) to 192.168.1.153:61771 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.153:61771;branch=z9hG4bKPja185ea9bc5ac4f3db585edc554cbce36;received=192.168.1.153;rport=61771
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25393 INVITE
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Contact: <sip:888@192.168.1.120:5060>
Content-Length: 0


<------------>
Audio is at 17172
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<--- Reliably Transmitting (NAT) to 192.168.1.153:61771 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.153:61771;branch=z9hG4bKPja185ea9bc5ac4f3db585edc554cbce36;received=192.168.1.153;rport=61771
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25393 INVITE
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Contact: <sip:888@192.168.1.120:5060>
Content-Type: application/sdp
Content-Length: 694

v=0
o=root 509783810 509783811 IN IP4 192.168.1.120
s=Asterisk PBX 18.14.0
c=IN IP4 192.168.1.120
t=0 0
m=audio 17172 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=ice-ufrag:3712adae561b6c630805226c087e1393
a=ice-pwd:14afa3b619878c4d73e5865769c00741
a=candidate:Hc0a80178 1 UDP 2130706431 192.168.1.120 17172 typ host
a=candidate:Sea12eff 1 UDP 1694498815 14.161.46.255 61972 typ srflx raddr 192.168.1.120 rport 17172
a=candidate:Hc0a80178 2 UDP 2130706430 192.168.1.120 17173 typ host
a=candidate:Sea12eff 2 UDP 1694498814 14.161.46.255 61973 typ srflx raddr 192.168.1.120 rport 17173
a=rtcp-mux
a=sendrecv

<------------>
    -- <SIP/105-000000f7> Playing '/var/lib/asterisk/sounds/en/999/default.slin' (language 'en')
       > 0x561aba8efce0 -- Strict RTP switching to RTP target address 192.168.1.153:4050 as source
Retransmitting #2 (NAT) to 192.168.1.121:5062:
OPTIONS sip:192.168.1.121 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.120:5060;branch=z9hG4bK726d85ce;rport
Max-Forwards: 70
From: "asterisk" <sip:asterisk@192.168.1.120>;tag=as7f72be1e
To: <sip:192.168.1.121>
Contact: <sip:asterisk@192.168.1.120:5060>
Call-ID: 1045a19174f55a741527c63376762e41@192.168.1.120:5060
CSeq: 102 OPTIONS
User-Agent: primas
Date: Wed, 05 Jul 2023 09:13:03 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Content-Length: 0


---
Retransmitting #1 (NAT) to 192.168.1.153:61771:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.153:61771;branch=z9hG4bKPja185ea9bc5ac4f3db585edc554cbce36;received=192.168.1.153;rport=61771
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25393 INVITE
Server: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
Contact: <sip:888@192.168.1.120:5060>
Content-Type: application/sdp
Content-Length: 694

v=0
o=root 509783810 509783811 IN IP4 192.168.1.120
s=Asterisk PBX 18.14.0
c=IN IP4 192.168.1.120
t=0 0
m=audio 17172 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=ice-ufrag:3712adae561b6c630805226c087e1393
a=ice-pwd:14afa3b619878c4d73e5865769c00741
a=candidate:Hc0a80178 1 UDP 2130706431 192.168.1.120 17172 typ host
a=candidate:Sea12eff 1 UDP 1694498815 14.161.46.255 61972 typ srflx raddr 192.168.1.120 rport 17172
a=candidate:Hc0a80178 2 UDP 2130706430 192.168.1.120 17173 typ host
a=candidate:Sea12eff 2 UDP 1694498814 14.161.46.255 61973 typ srflx raddr 192.168.1.120 rport 17173
a=rtcp-mux
a=sendrecv

---

<--- SIP read from UDP:192.168.1.153:61771 --->
ACK sip:888@192.168.1.120:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPj686c984f533341c099d80df2e65d2cc3
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25393 ACK
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---

<--- SIP read from UDP:192.168.1.153:61771 --->
ACK sip:888@192.168.1.120:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.153:61771;rport;branch=z9hG4bKPj686c984f533341c099d80df2e65d2cc3
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
To: <sip:888@192.168.1.120>;tag=as2bf1fb24
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 25393 ACK
Content-Length: 0

---
    -- Executing [888@from-outside3:2] SIPAddHeader("SIP/105-000000f7", "X-CallerID:<105>") in new stack
    -- Executing [888@from-outside3:3] NoOp("SIP/105-000000f7", "SIP Header:") in new stack
    -- Executing [888@from-outside3:4] Dial("SIP/105-000000f7", "SIP/106,,G(from-outside4,106,1)") in new stack
  == Using SIP RTP CoS mark 5
Audio is at 14864
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 192.168.1.153:61642:
INVITE sip:106@192.168.1.153:61642;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.1.120:5060;branch=z9hG4bK4485f5e7;rport
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=as3f3353c5
To: <sip:106@192.168.1.153:61642;ob>
Contact: <sip:105@192.168.1.120:5060>
Call-ID: 37e0581976e5225425e8458c2167e0f0@192.168.1.120:5060
CSeq: 102 INVITE
User-Agent: primas
Date: Wed, 05 Jul 2023 09:13:07 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
X-CallerID: <105>
Remote-Party-ID: "105" <sip:105@192.168.1.120>;party=calling;privacy=off;screen=no
Content-Type: application/sdp
Content-Length: 265

v=0
o=root 1619600302 1619600302 IN IP4 192.168.1.120
s=Asterisk PBX 18.14.0
c=IN IP4 192.168.1.153
t=0 0
m=audio 4050 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=rtcp-mux
a=sendrecv

---
    -- Called SIP/106

<--- SIP read from UDP:192.168.1.153:61642 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.120:5060;rport=5060;received=192.168.1.120;branch=z9hG4bK4485f5e7
Call-ID: 37e0581976e5225425e8458c2167e0f0@192.168.1.120:5060
From: <sip:105@192.168.1.120>;tag=as3f3353c5
To: <sip:106@192.168.10.233;ob>
CSeq: 102 INVITE
Content-Length: 0

---
Really destroying SIP dialog '1045a19174f55a741527c63376762e41@192.168.1.120:5060' Method: OPTIONS

<--- SIP read from UDP:192.168.1.153:61642 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.120:5060;rport=5060;received=192.168.1.120;branch=z9hG4bK4485f5e7
Call-ID: 37e0581976e5225425e8458c2167e0f0@192.168.1.120:5060
From: <sip:105@192.168.1.120>;tag=as3f3353c5
To: <sip:106@192.168.10.233;ob>;tag=f93dc719c5354bb6887cbc3f4f9c7f92
CSeq: 102 INVITE
Contact: <sip:106@192.168.1.153:61642;ob>
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---
sip_route_dump: route/path hop: <sip:106@192.168.1.153:61642;ob>
Really destroying SIP dialog '1755c34048b056a409bcc38004012ff3@192.168.1.120:5060' Method: OPTIONS
    -- SIP/106-000000f8 is ringing
Really destroying SIP dialog '2b0af15f4717c58b-52183@127.0.0.1' Method: OPTIONS
Audio is at 17172
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 192.168.1.153:61771:
INVITE sip:105@192.168.1.153:61771;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.1.120:5060;branch=z9hG4bK5bf8cf4f;rport
Max-Forwards: 70
From: <sip:888@192.168.1.120>;tag=as2bf1fb24
To: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
Contact: <sip:888@192.168.1.120:5060>
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 102 INVITE
User-Agent: primas
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
X-asterisk-Info: SIP re-invite (External RTP bridge)
Content-Type: application/sdp
Content-Length: 694

v=0
o=root 509783810 509783812 IN IP4 192.168.1.120
s=Asterisk PBX 18.14.0
c=IN IP4 192.168.1.120
t=0 0
m=audio 17172 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=ice-ufrag:3712adae561b6c630805226c087e1393
a=ice-pwd:14afa3b619878c4d73e5865769c00741
a=candidate:Hc0a80178 1 UDP 2130706431 192.168.1.120 17172 typ host
a=candidate:Sea12eff 1 UDP 1694498815 14.161.46.255 61972 typ srflx raddr 192.168.1.120 rport 17172
a=candidate:Hc0a80178 2 UDP 2130706430 192.168.1.120 17173 typ host
a=candidate:Sea12eff 2 UDP 1694498814 14.161.46.255 61973 typ srflx raddr 192.168.1.120 rport 17173
a=rtcp-mux
a=sendrecv

---

<--- SIP read from UDP:192.168.1.153:61771 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.120:5060;rport=5060;received=192.168.1.120;branch=z9hG4bK5bf8cf4f
Call-ID: eec5eee355ec46b6bf2f9740612851dd
From: <sip:888@192.168.1.120>;tag=as2bf1fb24
To: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
CSeq: 102 INVITE
Contact: <sip:105@192.168.1.153:61771;ob>
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub, trickle-ice
Content-Type: application/sdp
Content-Length: 320

v=0
o=- 3897562385 3897562387 IN IP4 192.168.1.153
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4050 RTP/AVP 0 101
c=IN IP4 192.168.1.153
b=TIAS:64000
a=rtcp:4051 IN IP4 192.168.10.233
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ssrc:1086587744 cname:6984355309ae4e75
<------------->
--- (11 headers 15 lines) ---
Comparing SDP version 3897562386 -> 3897562387 and unique parts [- 3897562385 IN IP4 192.168.1.153] -> [- 3897562385 IN IP4 192.168.1.153]
Found RTP audio format 0
Found RTP audio format 101
Found audio description format PCMU for ID 0
Found audio description format telephone-event for ID 101
Capabilities: us - (opus|ulaw|alaw|gsm), peer - audio=(ulaw)/video=(nothing)/text=(nothing), combined - (ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 192.168.1.153:4050
Transmitting (NAT) to 192.168.1.153:61771:
ACK sip:105@192.168.1.153:61771;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.1.120:5060;branch=z9hG4bK797f25e4;rport
Max-Forwards: 70
From: <sip:888@192.168.1.120>;tag=as2bf1fb24
To: <sip:105@192.168.1.120>;tag=0d6b1ffe4799409fbb823bfedaa28564
Contact: <sip:888@192.168.1.120:5060>
Call-ID: eec5eee355ec46b6bf2f9740612851dd
CSeq: 102 ACK
User-Agent: primas
Content-Length: 0

Is this the incoming leg you were talking about? I’m not sure. Please tell me if you need

That is the incoming INVITE, which contains no “X-CallerID” header so SIP_HEADER would not return anything.

also i these are my context

105@my-server.com are using [from-outside3] context
106@my-server.com are using [from-outside4] context

That doesn’t alter my answer. There is no X-CallerID header that has been received that I can see, so SIP_HEADER will return nothing.

Audio is at 14864
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 192.168.1.153:61642:
INVITE sip:106@192.168.1.153:61642;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.1.120:5060;branch=z9hG4bK4485f5e7;rport
Max-Forwards: 70
From: <sip:105@192.168.1.120>;tag=as3f3353c5
To: <sip:106@192.168.1.153:61642;ob>
Contact: <sip:105@192.168.1.120:5060>
Call-ID: 37e0581976e5225425e8458c2167e0f0@192.168.1.120:5060
CSeq: 102 INVITE
User-Agent: primas
Date: Wed, 05 Jul 2023 09:13:07 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces
X-CallerID: <105>
Remote-Party-ID: "105" <sip:105@192.168.1.120>;party=calling;privacy=off;screen=no
Content-Type: application/sdp
Content-Length: 265

We’re talking about this block. It has X-CallerID: <105>. Sorry i’m not with you right now. Probably not understand so can you provide me with more information about what’re you talking about

That is an outgoing INVITE for an outgoing call.

The SIP_HEADER dialplan function retrieves headers from an INCOMING INVITE. An incoming call.

So sir. What if i want to transfer a data from caller_1 to caller_2 should i keep using Custom Header

You can, yes. You can read a header from the incoming side and set it on the outgoing side, or set it on the outgoing side with other information like you’ve already done with callerid number.

Then how can we tell if the log is belong to an incoming request or an outgoing request sir? thank you

I don’t understand the question. What log? For what purpose?

All of the above logs that i posted. How can i tell if it come from an incoming request or not

“SIP read from” means the SIP request came from a device. “Transmitting” means Asterisk sent it. If you want to learn how to debug SIP stuff, then you’d need to learn more about SIP itself.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.