Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 

A guide to SIP Normalization on CUCM and Lua Scripting

Cisco Employee

 

(view in My Videos)

 

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.

88 Comments

Very good video Sreekanth, Thanks for sharing it. It'd be nice if we could get those sample scripts you explained ;)

Cisco Employee

Thanks for your comment Suresh! It is easy to cook the scripts up. Which one were you looking for?

I'm trying to modify the History-info to Diversion, tried the below script.

 

M = {}
M.allowHeaders = {"History-Info"}
function M.inbound_INVITE(msg)
local hisInfo = msg:getHeader("History-Info")
local start = string.find(hisinfo, "<")
local end_str = string.find(hisinfo, ">", start+1)
local target = string.sub(hisinfo, start, end_str)
local diversion = string.format("%s;reason=\"unconditional\"", target)
msg:addHeader("Diversion", diversion)
end
return M

 

Tried the Lua interpreter to execute the script and it showed the correct result.

 

HISTORY-INFO: <sip:+16048959049@uswsnn232.vcnqalab.dsqalab.volvo.net;user=phone>;index=1;ms-retarget-reason=forwarding,<sip:+918042072986@uswsnn232.vcnqalab.dsqalab.volvo.net;user=phone>;index=1.1


hisinfo = '<sip:+16048959049@uswsnn232.vcnqalab.dsqalab.volvo.net;user=phone>;index=1;ms-retarget-reason=forwarding,<sip:+918042072986@uswsnn232.vcnqalab.dsqalab.volvo.net;user=phone>;index=1.1'

local start = string.find(hisinfo, "<")
local end_str = string.find(hisinfo, ">", start+1)
local target = string.sub(hisinfo, start, end_str)
local diversion = string.format("%s;reason=\"unconditional\"", target)

print (diversion)

RESULT:
<sip:+16048959049@uswsnn232.vcnqalab.dsqalab.volvo.net;user=phone>;reason="unconditional"

 

but the CUCM throws error at line number 5.

 

13:00:15.100 |SIPNormalizationScriptError - A script error occurred Device Name:SIP_CA_Lync_2013_Toll_QA Script Name:Simultaneous_Ring_Script Script Function:M.inbound_INVITE Script Type:Custom Error Code:3 Error Code Text:Execution Error Error Message:Simultaneous_Ring_Script at line 5: bad argument #1 to 'find' (string expected, got nil) Configured Action:Rollback Only Resulting Action:Rollback Only In Use Memory:1946 Memory Threshold:51200 In Use Lua Instructions:0 Lua Instruction Threshold:1000

>> could you please have a check on this? will open a thread in support form if needed :)

ok, found & fixed the issue of the case sensitive variable :)

local hisInfo = msg:getHeader("History-Info")

defined the valiable as "hisInfo" but called it without block letter I, hisinfo other places.

Cisco Employee

Nicely done! The find function wasn't getting any value.

Excellent Post. Thank you for this. Helped me out a lot!

John

Cisco Employee

Thanks for your feedback John!

New Member

GREAT! This is how to transmit experience. So important the SIP interop stuff. Thanks so much.This is Cisco SOLUTIONS.. :-) Thanks!!

Cisco Employee

Thanks ahenne! Glad you like the post :)

Hi Team !

i have the same Issue ! the SIP Provider ask me to change the Invite and the From

now my CUCM is sending the Invite and From like this

INVITE sip:06923848585@217.10.68.150:5060 SIP/2.0
> Via: SIP/2.0/UDP 10.10.10.251:5060;branch=z9hG4bKc013179554
> From: <sip:021163558628806@10.10.10.251>;tag=3535~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-

 

i have to modified it like this:

INVITE sip:20xx005t0@sipconnect.sipgate.de SIP/2.0
> Via: SIP/2.0/UDP 10.10.10.251:5060;branch=z9hG4bKc013179554
> From: <sip:20xx005t0@10.10.10.251>;tag=3535~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-

 

Please can you help send me the Script template for my change !

Thanks in advance

Cisco Employee

Hi Alain,

 

We cannot change the Request URI unless it is going to the same number every time.

There is an API setRequestUri which is used to set the URI on the INVITE message.

http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cucm/sip_tn/8_5_1/sip_t_n/3-sip_msg.html#wp1071744

 

I suggest using number translation on the route pattern or translation pattern on the CUCM itself before sending the call out over the SIP trunk.

As for the domain name that you need to send to, if you have DNS enabled, you can point the SIP trunk at sipconnect.sipgate.de. This will populate it in the URI.

 

For changing the From header, again, you can invoke Calling Party transformation to make the changes, or if you really want to use normalization, then use the getHeader API to get the contents of the From message and then replace the number. You'll need to figure out a pattern first because the calling number can be different for each call.

 

Thanks

 

Hi Screekanth,

thanks for your prompt replay. you are wright ! i am not trying to change the URI th am trying to change only the route Pattern

 

the Only change hier is

INVITE sip:06923848585------------  to INVITE sip:20xx005t0

and

From: <sip:021163558628806 ------ to From: <sip:20xx005t0

 

how to do it ?

 

 

Cisco Employee

Are these static changes that you want to make? Will it always be the same numbers?

And in 20xx005t0, does the XX mean a 2 digit number? What is the 't' here for?

yes it will alwas be the same nr and the xx are digits the t is there

 

this nr is my SIP ID and the provider need it to AUthenticate me
 

hi

ANY NEWS ?

i test this script but no Change

 

M = {}
function M.outbound_INVITE(msg)
 msg:modifyHeader("Contact", "2099006t0")

end
return M

 

for my understanding i cann only Change the From  

Question it is possible to Change the From

 

From: <sip:"SIPID"@10.10.10.251>;tag=3535~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-

 

Cisco Employee

If the script doesn't change the message, then you'll need to take the traces on the CUCM to see if the script got executed and hit some error.

You will need detailed CUCM traces for it.

Yes you can change the From.

M={}

function M.outbound_INVITE(msg)

    local from = msg:getHeader("From")

    local b = string.gsub(a, "(<sip:.+@)", "<sip:200xxt50@")

    msg:modifyHeader("From", b)

end

return M

   

Hi Thanks for your replay ! but i still have error

 

00226559.005 |20:28:49.629 |AlarmErr |AlarmClass: CallManager, AlarmName: SIPNormalizationScriptError, AlarmSeverity: Error, AlarmMessage: , AlarmDescription: A script error occurred, AlarmParameters: DeviceName:NS_SIP_TRUNK, ScriptName:sipgate, ScriptFunction:M.outbound_INVITE, ScriptType:Custom, ErrorCode:3, ErrorCodeText:Execution Error, ErrorMessage:sipgate at line 7: bad argument #1 to 'gsub' (string expected, got nil), ConfiguredAction:Rollback Only, ResultingAction:Rollback Only, InUseMemory:1306, MemoryThreshold:51200, InUseLuaInstructions:0, LuaInstructionThreshold:1000, AppID:Cisco CallManager, ClusterID:StandAloneCluster, NodeID:NS-CUCM,

 

Also both the INVITE line and the FROM field appear to be unchanged:

 

Cisco Employee

Thats because the string.gsub function is getting 'a' as the first argument. Change it to from, because that is the variable.

local b = string.gsub(from, "(<sip:.+@)", "<sip:200xxt50@")

hi just get the ISP

there are expecting this informations:

 INVITE sip:021163553355@sipconnect.sipgate.de:5060 SIP/2.0

To: sip:021163553355@sipconnect.sipgate.de:5060

From: sip:SIP-ID@sipconnect.sipgate.de:5060;tag=c32f2811

 

My CUCS is sending :

INVITE sip:496917320884@sipconnect.sipgate.de:5060 SIP/2.0   is ok

From: <sip:4921163558628806@10.10.10.251>;tag=2044~14bb5db7-95a9-4db0-864a-a21a1f2e14ad-18282657  not ok

To: <sip:496917320884@sipconnect.sipgate.de>  is ok

we only have to Change the from Line

Thanks

Hi Screekanth !

THANKS A LOT for your Help ! ! the Trunk is UP now ! i just have tu Setup the CUCM correctly to get the Phone working

 

Thanks Thanks

Cisco Employee

Great! Enjoy scripting further!

New Member

Hello, how can I Download the Video?

Regards

Armin

Cisco Employee

Hi Armin,

I don't think you can download this video unfortunately. Only the streaming option is allowed.

 

Thanks

New Member

Hi Sreekanth,

Firstly.. the video was informative and provided a good insight on the subject. So thanks for the tutorial.

My query is: Is it possible to do a Ldap lookup in the script for replacing/ adding values to the "From" field based on the name associated with the number in the Ldap?

eg. If a number 4444 (a third party device not capable of forwarding caller id info - clid/cnid) is making a call to a cisco call manager cluster and the number 4444 is associated with the name "XXX" in LDAP, would it be possible to show XXX in the caller id instead of 4444?

Thanks in advance.

Cisco Employee

Hi Alan,

 

Thanks for your kind words. Glad it helped.

No, unfortunately, such API has not been provided by the developers. We cannot run functions that call the LDAP search and perform actions on the output.

You will need to figure out a pattern and then make changes based on "if" conditions in the script.

 

Thanks

Hi Sreekanth,

 

I find this thread very useful, but i have a question, do you know if there is any recommendations for the Memory and LUA instructions thresholds? I assume it may be dependant on the load of the server or even on the size of the script.

 

Thanks in advance.

 

Carlos M. 

Cisco Employee

Hi Carlos,

No, there isn't any recommendation for memory and lua instruction thresholds.

 

Thanks

Sreekanth

New Member

Hi Mr Sreekanth,

 

Very good and informative video!!

I have the same requirement as posted below by Alan Baker. 

I know there are no functions that call the LDAP search and perform actions on the output.

Is there any workaround to that? I mean maybe i can save all my contacts in an external file and maybe perform a search there to map the usernames?

Please suggest something. There are around 14000 users!

 

Thanks in advance.

 

Akshay

Cisco Employee

Hi Akshay,

 

Thanks for your kind words!

Unfortunately, no, we can't parse a file located on the CUCM and link that to the sip normalization script. The workaround would need to performed out of the scope of the normalization script.

 

Regards,

Sreekanth

New Member

Hi Sreekanth,

 

How can I get the remote-party-id script?

 

Best Regards

Bahlul

Cisco Employee

Hi Bahlul,

 

unfortunately the video cannot be downloaded from the platform. That option is not available.

 

Regards

Sreekanth

Cisco Employee

You could try using AXL to achieve the above requirement. The AXL can be used to query user parameters and perform actions based on the data received from the CUCM.

New Member

Hello Sreekanth,

How can I get Remote-party-ID script? because I've a problem with GSM gateway, when I'm calling to mobile through gsm gateway, call is going normal, and we can hear each-other, but when I'm transferring the call, there is no rtp. And I have attached jpg file, please see it.

 

 

Best regards

Bahlul

Cisco Employee

Hello Bahlul,

For removing the RPID header, you can use the removeHeader function. For instance if you want to remove the RPID from the incoming Invite.

 

M={}

function M.inbound_INVITE(msg)

    msg:removeHeader("Remote-Party-ID")

end

return M

New Member

Dear Sreekanth,

This script didn't help.

 

Best Regards

Bahlul

Cisco Employee

The script only removes the RPID header for inbound invites. Is that what you require? What are the IP addresses in the jpg?

New Member

The 10.10.14.253 is cucm ip address.

The 10.10.14.17 is gsm gateway ip address

 

Best regards

Bahlul

Cisco Employee

It looks like you require the outbound Invite to be modified and not the inbound invite.

Please change the script to:

M={}

function M.outbound_INVITE(msg)

    msg:removeHeader("Remote-Party-ID")

end

return M

 

Apply this to the trunk, save and reset it, and then try the call.

New Member

I did it but there is no result ((

 

Best regards

Bahlul

Cisco Employee

The indentation of the script matters. The 'end' and 'return M' lines should be aligned to the left. Also please remove any additional spaces at the end of each line or any extra lines added

New Member

I have changed the script but there is no result again.

 

Best regards

Bahlul

Cisco Employee

Hmmm, we will need to check the trace files to see what's happening on the CUCM. That will tell us why the profile did not work. I suggest you enable the SIP Call processing and SIP Stack traces on the CUCM to detailed level and try the call, then check the trace.

New Member

These traces are active. How can I download these trace logs? Is these trace files include the call manager trace files which is downloadable from RTMT?

 

Best Regards

Bahlul

New Member

I've called to mobile number (mob number : 0506707636), and collected the cucm trace.

 

please see attached file.

 

Best regards

Bahlul

Cisco Employee

In the traces, I'm not seeing the normalization script being invoked at all. We can see the cucm sending out the Invite without invoking normalization.

 

51000611.001 |15:48:39.064 |AppInfo  |//SIP/SIPUdp/wait_SdlSPISignal: Outgoing SIP UDP message to 10.10.14.17:[5060]:
[1887876,NET]
INVITE sip:0506707636@10.10.14.17:5060 SIP/2.0

 

51002383.001 |15:48:57.450 |AppInfo  |//SIP/SIPUdp/wait_SdlSPISignal: Outgoing SIP UDP message to 10.10.14.17:[5060]:
[1887913,NET]
INVITE sip:0506707636@10.10.14.17 SIP/2.0

 

51004100.001 |15:49:10.394 |AppInfo  |//SIP/SIPUdp/wait_SdlSPISignal: Outgoing SIP UDP message to 10.10.14.17:[5060]:
[1887940,NET]
INVITE sip:0506707636@10.10.14.17 SIP/2.0

 

If the normalization script was invoked, we'd at least see 'before normalization' and  'after normalization' phrases in the traces.

New Member

please check this file

 

Best regards

Bahlul

Cisco Employee

I'm seeing the same thing again. It still looks like the script is not even invoked by the sip trunk.

 

I can see that the trunk NeoGate is chosen by the digit analysis.

51048097.005 |16:15:33.606 |AppInfo  |SIPCdpc(18893) - LocalizeOutpulsedNumber: SIPCdpc on device NeoGate , CSS = ,useDevicePoolCgpnCss =1 AlternateCgpn(global)=1202  cgpn=1202, cdpn=0506707636, mUpdateInstruction=0

 

 

51049349.001 |16:15:45.218 |AppInfo  |//SIP/SIPUdp/wait_SdlSPISignal: Outgoing SIP UDP message to 10.10.14.17:[5060]:
[1888690,NET]
INVITE sip:0506707636@10.10.14.17 SIP/2.0

 

 

51050125.001 |16:15:53.475 |AppInfo  |//SIP/SIPUdp/wait_SdlSPISignal: Outgoing SIP UDP message to 10.10.14.17:[5060]:
[1888704,NET]
INVITE sip:0506707636@10.10.14.17 SIP/2.0

 

 

New Member

Dear Sreekanth,

How can I invoke this script? What I need to to do?

I'd choose this script under SIP trunk. But still no result

 

Best Regards

Bahlul

Cisco Employee

Dear Bahlul,

If the script is not invoked despite adding it to the sip trunk it could be a bug on cucm, because we have made sure the script is formatted correctly.

Please try changing the header we are trying to remove, like the Contact, or P-Asserted-ID and see if that works. What is the complete cucm version? (a.b.c.ddddd-e)

2855
Views
30
Helpful
88
Comments