cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
45585
Views
65
Helpful
92
Comments
Sreekanth Narayanan
Cisco Employee
Cisco Employee

 

 

I have recorded this guide for SIP Normalization on call manager and also have elaborated a little bit on how we use the Lua scripting.

 

A SIP Normalization script could really help the customer as a workaround or a permanent solution for issues related to calling and CLID.

 

Disclaimer:

Cisco TAC does NOT support SIP Normalization scripts. If the customer has already applied a script, TAC does NOT troubleshoot it. It is the customer's responsiblity to make it work.

92 Comments
Sreekanth Narayanan
Cisco Employee
Cisco Employee

Hi Jen,

Is the change reflected on the request URI line? You have pasted the Remote party ID line. The script will not change the RPID header. It changes only the URI. If you want the change on the RPID, the the script has to be :

M = {}
function M.outbound_INVITE(msg)
    local method, ruri, ver = msg:getRequestLine()

    local rpid = msg:getHeader("Remote-Party-ID")

    local uri = string.gsub (ruri, '10.90.2.10', 'nmic-ccm-02.noridian.com')

    local new_rpid = string.gsub (rpid, '10.90.2.10', 'nmic-ccm-02.noridian.com')

    msg:setRequestUri(uri)

    msg:modifyHeader("Remote-Party-ID", new_rpid)
end
return M

majszakm
Level 1
Level 1

Hi Sreekanth, thanks for the post, wondering if you could help me with my script, am not able to get it to work and have tried several different versions. What I'm attempting to do is manipulate the media-level content. The reason I'm attempting to do this is, UCM is talking to a 3rd party IVR via a SIP trunk, and when the call connects from UCM to the IVR, the IVR doesn't include the DTMF method it supports and as a result when DTMFs are pressed UCM doesn't send any of them to the 3rd party IVR. The following is the latest version of my SIP Normalization script that fails to work, and below that is the debug info:

 

M = {}

function M.inbound_ANY_ANY(msg)

                local sdp = msg:getSdp()

                if sdp

                then

                                local DTMF_line1 = sdp:getLine("m=","RTP/AVP 0")

                                local DTMF_line2 = sdp:getLine("a=","PCMU/8000")

                                if DTMF_line1

                                then

                                                DTMF_line1 = DTMF_line1:gsub("RTP/AVP 0", "RTP/AVP 100")

                                                sdp = sdp:modifyLine("m=", "RTP/AVP 0", DTMF_line1)

                                                DTMF_line2 = DTMF_line2:gsub("PCMU/8000", "telephone-event/8000")

                                                sdp = sdp:modifyLine("a=", "PCMU/8000", DTMF_line2)

                                                sdp = sdp:addLine("a=fmtp:100 0-15,66,70\r\n")

                                                msg:setSdp(sdp)

                                end

                end

end

return M

 

 

Debug output:

 

SIP/2.0 200 OK
From: "JohnDoe - 674453"<sip:674453@10.16.244.10>;tag=5670235~3c42c8be-1fb9-4ca5-8b79-7149b62abf9b-34084917
To: <sip:674441@192.168.10.10>;tag=9000fe0-9250020a-13c4-55013-49077-288f82b7-49077
Call-ID: c4d67180-5d610ab8-137d25-cad1dac@10.16.244.10
CSeq: 101 INVITE
Via: SIP/2.0/UDP 10.16.244.10:5060;branch=z9hG4bK76b66268c49e4
Supported: 100rel
User-Agent: Brktsip/6.7.1B3 (Dialogic)
Contact: <sip:192.168.10.10:5060>
Content-Type: application/sdp
Content-Length: 146

v=0
o=- 2209294725 0302487000 IN IP4 192.168.10.10
s=no_session_name
t=0 0
m=audio 56008 RTP/AVP 0
c=IN IP4 192.168.10.10
a=rtpmap:0 pcmu/8000

 

|//SIP/SIPNormalization/trace_sip_message: After inbound (no change) SIP Normalization msg is:
[28908603,INT]


SIP/2.0 200 OK
From: "JohnDoe - 674453"<sip:674453@10.16.244.10>;tag=5670235~3c42c8be-1fb9-4ca5-8b79-7149b62abf9b-34084917
To: <sip:674441@192.168.10.10>;tag=9000fe0-9250020a-13c4-55013-49077-288f82b7-49077
Call-ID: c4d67180-5d610ab8-137d25-cad1dac@10.16.244.10
CSeq: 101 INVITE
Via: SIP/2.0/UDP 10.16.244.10:5060;branch=z9hG4bK76b66268c49e4
Supported: 100rel
User-Agent: Brktsip/6.7.1B3 (Dialogic)
Contact: <sip:192.168.10.10:5060>
Content-Type: application/sdp
Content-Length: 146

v=0
o=- 2209294725 0302487000 IN IP4 192.168.10.10
s=no_session_name
t=0 0
m=audio 56008 RTP/AVP 0
c=IN IP4 192.168.10.10
a=rtpmap:0 pcmu/8000

 

 

 

 

 

Sreekanth Narayanan
Cisco Employee
Cisco Employee

Hello!

From the call flow you have told me, it looks like the CUCM is sending the 200 ok.

If the SIP trunk has DTMF preference set to OOB and RFC2833 the CUCM should automatically add this method to the 200 ok message SDP. If the far end IVR doesn't send the payload in the sdp in any of the messages, it should at least support OOB method of dtmf.

Unless the method is advertised by the 3rd party IVR, even if we send them rtp-nte events with payload, they would discard these packets.

Have they said they'll accept the dtmf method if we send it to them without them advertising it?

 

Thanks

 

majszakm
Level 1
Level 1

Thanks Sreekanth, yes, the 3rd party is saying that they'll accept the dtmf method even though they are not advertising it.

Sreekanth Narayanan
Cisco Employee
Cisco Employee

Ok in that case, we only need to make the changes on the inbound Invite message coming from the 3rd party IVR. Please change the message that the function applies to to Invite.

function M.inbound_INVITE(msg)

If the IVR is doing delayed offer, even if we change the 200 ok message to contain the rtp-nte payload, the ACK from their side won't contain the payload and that would cause the CUCM to stop sending the rtp-nte packets.

 

majszakm
Level 1
Level 1

Thanks Sreekanth, will give that a try. 2 questions, wouldn't the "function M.inbound_ANY(msg)" or the function M.inbound_ANY_ANY(msg)", have done the same? My other question is, if the IVR is actually doing delayed offer, is there nothing that can be done to force UCM to send the DTMFs?

pavelekshin
Level 1
Level 1

Hi ,

Do you know it's real to realize inbound number2name script with Lua?

How to create local database for it

pavelekshin
Level 1
Level 1

Looks like this should work, for catching number and return the name

 

database =
{
 {name="first", number="1104"},
 {name="second", number="1105"},
 {name="Third", number="1106"}
}

find = '1106'

for i=1, #database do
 if string.find(database[i].number, find)
 then
   get = database[i].name
end
end

 

 

Which header i should modify for convert number to name into UCM ? From / RPId ?

pavelekshin
Level 1
Level 1

del

solomonluke
Level 4
Level 4

I am trying to grab the extension from the refered-by line and use it to update the From of the invite. I have tested this script in Lua editor but it wont work in CUCM.

refer = '<sip:servername.com;c=ms-ova-data;v=1.0;Extension=6616>'

M = {}

function M.inbound_REFER(msg)
local refer = msg:getHeader("REFERRED-BY")

local rstart = string.find(refer, "n=")
local rresult = string.sub(refer, rstart)
local rchange = string.gsub(rresult, "n=", "")
local rfchange = string.gsub(rchange, ">", "")
end
function M.outbound_INVITE(msg)
local from = msg:getHeader("From")
local fromchange = string.gsub(from, "7899", rfchange)
msg:modifyHeader("From", fromchange)
end
return M

Thanks,
Solomon

pwhite
Level 1
Level 1

Thanks for this great tutorial.  I am unsuccessfully attempting to implement your fromchange script.  Here is the code that I'm using.  Any ideas on why this woulnt have the desired effect of changing the From name to TEST?  In looking at a SIP Invite message in the trace files, I noticed that the FROM portion of the message was capitalized, so I made that adjustment to the script.

M={}
function M.outbound_INVITE(msg)
local from = msg:getHeader("FROM")
local start = string.find(from, "\"")
local end = string.find(from, "\"", start+1)
local target = string.sub(from, start, end)
local fromchange = string.gsub(from, target, "TEST")
msg:modifyHeader("FROM", fromchange)
end
return M

thouck001
Level 1
Level 1

hello Sreekanth

im trying to work on a script that will change the p-assert and diversion for inbound only if some criteria s are meet. it fails when i try this each time so i wanted to do if this scipt is positioned to correctly flow or if there is an issue in it. Thanks

F2P
function F2P.inbound_INVITE(msg)
 local fromString = msg:getUri("From")
 if fromString
 then
  local from = sipUtils.parseUri(fromString)
  if from
  then
   local from user = uri:getUser()
   if from user
   then
    if "from user" = ("9866XXXXXXX")
    then
     msg:applyNumberMask("P-Asserted-Identity", "from user")
     msg:applyNumberMask("Diversion", "6154685660")
     end
    if "from user" = ("9877XXXXXXX")
     then
     msg:applyNumberMask("P-Asserted-Identity", "from user")
     msg:applyNumberMask("Diversion", "6154685660")
    end
    if "from user" = ("91866XXXXXXX")
    then
     msg:applyNumberMask("P-Asserted-Identity", "from user")
     msg:applyNumberMask("Diversion", "6154685660")
    end
    if "from user" = ("91877XXXXXXX")
    then
     msg:applyNumberMask("P-Asserted-Identity", "from user")
     msg:applyNumberMask("Diversion", "6154685660")
    end
   end
  end
 end
end

GadgetFood
Level 1
Level 1

How can I get to the video for this guide?  I don't see a link or url.

chrischelvy
Level 1
Level 1

Hi Sreekanth,

                          i have a SIP trunk setup between the CUCM and VCS. Any incoming calls from VCS to CUCM , we see the from address is "name@domain". we want to convert the Prefix part of the SIP URI from " name" to any number like 50000.

Basically, for any inbound calls via SIP trunk, we need to convert like below.

name@domain  ---> 50000@domain.

I have tried couple of examples above, but none of them worked. Can you please help on this script?.

Thanks

Chris

kkh_sninebuck
Level 1
Level 1

hello pwhite,

later in his video, sreekanth mentions you can not use system operators like "end" as a variable in your script. therefor he named that variable end_string in his example. Also thanks for the great tutorial!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links