cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
44418
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

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.

Bahlul Guliyev
Level 1
Level 1

please check this file

 

Best regards

Bahlul

Sreekanth Narayanan
Cisco Employee
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

 

 

Bahlul Guliyev
Level 1
Level 1

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

Sreekanth Narayanan
Cisco Employee
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)

Jen Zachariason
Level 1
Level 1

Hi Sreekanth,

We are working trying to send the Fully Qualified Domain Name (FQDN) to out IVR rather than the IP address.  They are saying that the address in the invite must match the name of the associated cert, which is the FQDN.  Would you be able to help me Understand why what we have created has not worked?  Below you will find the script that we have come up with.

 

M = {}

function M.outbound_INVITE(msg)

local method, ruri, ver = msg:getRequestLine()

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

msg:setRequestUri(uri)

end

 

return M

 

Thanks,

Jen Z

Giovanni Ceci
Level 1
Level 1

I hope you're resetting the SIP trunk after applying the script. If you don't reset the trunk after applying the script, it's not going to invoke.

Hi Sreekanth and all,

 

i am in the need to create a normalization script that changes values from the SIP Request URI, the To, the From and the Contact header for an incoming SIP Invite.

 

First i tried to change the Request URI, which worked fine. Then i extended my script to change the To Header, also. Now my script changes the To Header but the Request URI is not changed anymore.

Maybe anyone has an idea what is going wrong with my script.

 

My script:

 

M = {}
function M.inbound_INVITE(msg)
    local mwi_number_length = scriptParameters.getValue("MWI-Number-Length")
    
-- Get the SIP Request
    
    local method, ruri, version = msg:getRequestLine()    
    
-- Adjust SIP Request URI
    -- Get the first digits of the Request URI to form the new Called number
    
        local dnis_start = string.find(ruri, "%d")
        local dnis_end = dnis_start+mwi_number_length-1
        local dnis = string.sub(ruri, dnis_start, dnis_end)
    
    -- Get the rest of the digits of the Request URI to form the new Calling Number
    
        local ani_start = dnis_start+mwi_number_length
        local ani_end = string.find(ruri, "\@")
        local ani = string.sub(ruri, ani_start, ani_end-1)
        local ani = "\+" .. ani
    
    -- Get the Right Hand Side from the Request URI
    
        local host_start = string.find(ruri, "\@")
        local host_end = string.find(ruri, "%d", -1)
        local host = string.sub(ruri, host_start, host_end)
        local ruri_new = "sip:" .. dnis .. host
    
    -- Set the new Request URI
    
        msg:setRequestUri(ruri_new)
        
        
end

function M.inbound_INVITE(msg)
    local mwi_number_length = scriptParameters.getValue("MWI-Number-Length")    
            
-- Adjust SIP To Header
    -- Get the SIP To Header
    
        local to = msg:getHeader("To")
    
    -- Extract DNIS from SIP To Header
        
        local to_dnis_start = string.find(to, "%d")
        local to_dnis_end = to_dnis_start+mwi_number_length-1
        local to_dnis_new = string.sub(to, to_dnis_start, to_dnis_end)

    -- Extract RHS from SIP To Header
    
        local to_rhs = string.match(to, "\@.*")

    -- Create New SIP To Header
    
        local to_new = "<sip:" .. to_dnis_new .. to_rhs
            
    -- Set the new SIP To Header
        
        msg:modifyHeader("To", to_new)
        

end

 

Thanks in advance for any help or tip!

 

Original SIP Header:

 

INVITE sip:91249874993132993911@10.123.255.145:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 10.122.185.5:5060;branch=z9hG4bKQv9ZAYlmXawDkxKenpWp9g~~15
Max-Forwards: 70
To: <sip:91249874993132993911@10.123.255.145:5060>
From: <sip:9124980@10.122.185.5>;tag=dsddff2610
Call-ID: 143870139890020@10.122.185.5
CSeq: 100 INVITE
Content-Length: 189
Contact: <sip:9124980@10.122.185.5:5060;transport=udp>
Content-Type: application/sdp
Allow: INVITE, BYE, CANCEL, ACK, REFER, SUBSCRIBE, NOTIFY, INFO
Cisco-Gcid: F9492B74-014E-1000-5EE4-BDDE9F0E867D

<snip>

 

Needed SIP Header:

 

INVITE sip:9124987@10.123.255.145:5060;transport=udp SIP/2.0
Allow: INVITE, BYE, CANCEL, ACK, REFER, SUBSCRIBE, NOTIFY, INFO
From: <sip:4993132993911@10.122.185.5>;tag=dsddff2610
Content-Length: 189
To: <sip:9124987@10.123.255.145:5060>
Contact: <sip:4993132993911@10.122.185.5:5060;transport=udp>
Content-Type: application/sdp
Call-ID: 143870139890020@10.122.185.5
Via: SIP/2.0/UDP 10.122.185.5:5060;branch=z9hG4bKQv9ZAYlmXawDkxKenpWp9g~~15
CSeq: 100 INVITE
Max-Forwards: 70

 

/Robert

Sreekanth Narayanan
Cisco Employee
Cisco Employee

Hi Jen,

The reason it is not working is due to the " mark for the ip address. please try the script as follows:

M = {}
function M.outbound_INVITE(msg)
    local method, ruri, ver = msg:getRequestLine()
    local uri = string.gsub (ruri, '10.106.120.11', 'nmic-ccm-02.noridian.com')
    msg:setRequestUri(uri)
end
return M

 

Please make sure the indentation is right. The statements inside the function should be indented by 4 spaces and there should be no extra spaces or lines after each line.

Sreekanth Narayanan
Cisco Employee
Cisco Employee

Hi Robert,

Since your script was working when you had only the uri block, and then is working now only for the To field when you added the second block, it indicates that your function is working as expected.

Why don't you try modifying both the URI and the To field in the same function block? Why are they split into two? I'm guessing the SIP stack opens the script and because it's seeing 2 inbound_INVITE(msg), it only takes the second one into account and not the first. If you combine the modification of both URI and To in the same function, this should work.

Thanks
Sreekanth

Bahlul Guliyev
Level 1
Level 1

Dear Sreekanth,

I found the solution. Deselected MRGL from SIP Trunk, saved. Then selected the MRGL and it worked fine. Now I can call to Mobile numbers and transfer the calls.

 

 

Best Regards

Bahlul.

Sreekanth Narayanan
Cisco Employee
Cisco Employee

Dear Bahlul,

That's great! Thanks for the update. Not sure how the mrgl was related to the sip normalization. I've never seen this problem before!

Thanks

Sreekanth

Hi Sreekanth,

thanks for your tip. My script is working now.

 

Here is my working script:

 

M = {}

function M.inbound_INVITE(msg)

-- Get the MWI On/Off Numbers as Parameters from the CUCM Trunk Page

    mwiOnNumber = scriptParameters.getValue("MWI-On-Number")

    mwiOffNumberNumber = scriptParameters.getValue("MWI-Off-Number")

   

-- Get the SIP Request-URI

   

    method, ruri, version = msg:getRequestLine()   

   

-- SIP Request-URI: INVITE sip:91249884955566677788@10.123.255.145:5060 SIP/2.0

        -- Extract the Protocol Handler from SIP Request-URI

        ruriProtHandlerStart = string.find(ruri, "%a")

        ruriProtHandlerEnd = string.find(ruri,"\:")

        -- Set the Protocol Handler from SIP Request-URI

        ruriProtHandler = string.sub(ruri, ruriProtHandlerStart, ruriProtHandlerEnd)

   

-- Extract DNIS from SIP Request-URI

        dnisStart = string.find(ruri, "%d")

        mwiNumberLength = string.len(mwiOnNumber)

        dnisEnd = dnisStart+mwiNumberLength-1

        -- Set the New DNIS

        dnis = string.sub(ruri, dnisStart, dnisEnd)

 

-- Extract ANI from SIP Request-URI

        aniStart = dnisStart+mwiNumberLength

        aniEnd = string.find(ruri, "\@")

        ani = string.sub(ruri, aniStart, aniEnd-1)

        -- Set the New ANI

        aniNew = "\+" .. ani

       

 

-- Extract the Right Hand Side from SIP Request-URI

        ruriRhs = string.match(ruri, "\@.*")

        -- Set the new Right Hand Side from SIP Request-URI

        ruriNew = ruriProtHandler .. dnis .. ruriRhs

 

   

--  Get the SIP To Header: To: <sip:91249884955566677788@10.123.255.145>

    to = msg:getHeader("To")

        -- Extract the Protocol Handler from SIP To Header

        toProtHandlerStart = string.find(to, "\<")

        toProtHandlerEnd = string.find(to, "\:")

        toProtHandler = string.sub(to, toProtHandlerStart, toProtHandlerEnd)

        -- Extract the Right Hand Side from SIP To Header

        toRhsTag = string.match(to, "\@.*")

        -- Set the new SIP To Header

        toNew = toProtHandler .. dnis .. ruriRhs .. ">"

 

   

-- Get the SIP From Header: From: <sip:9124980@10.122.185.4>;tag=D6F709E8-144

    from = msg:getHeader("From")

        -- Extract the Protocol Handler from SIP From Header

        fromProtHandlerStart = string.find(from, "\<")

        fromProtHandlerEnd = string.find(from, "\:")

        fromProtHandler = string.sub(from, fromProtHandlerStart, fromProtHandlerEnd)

        -- Extract the Right Hand Side from SIP From Header

        fromRhsTag = string.match(from, "\@.*")

        -- Set the new SIP From Header

        fromNew =  fromProtHandler .. aniNew .. fromRhsTag

       

   

-- Get the SIP Contact Header: Contact: <sip:9124980@10.122.185.4:5060>

    contact = msg:getHeader("Contact")

        -- Extract the Protocol Handler from SIP Contact Header

        contProtHandlerStart = string.find(contact, "\<")

        contProtHandlerEnd = string.find(contact, "\:")

        contProtHandler = string.sub(contact, contProtHandlerStart, contProtHandlerEnd)

        -- Extract the Right Hand Side from SIP Contact Header

        contRhsTrans = string.match(contact, "\@.*")

        -- Set the new SIP Contact Header

        contNew =  contProtHandler .. aniNew .. contRhsTrans

 

 

-- Get the SIP Remote-Party-ID Header: Remote-Party-ID: <sip:9124980@10.122.185.4>;party=calling;screen=no;privacy=off

-- Only needed when the CUE is connecteed to CUCM through an IP-IP Gateway

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

        -- Extract the Protocol Handler from SIP Remote-Party-ID Header

        rpidProtHandlerStart = string.find(rpid, "\<")

        rpidProtHandlerEnd = string.find(rpid, "\:")

        rpidProtHandler = string.sub(rpid, contProtHandlerStart, contProtHandlerEnd)

        -- Extract the Right Hand Side from SIP Remote-Party-ID Header

        rpidRhsTrans = string.match(rpid, "\@.*")

        -- Set the new SIP Remote-Party-ID Header

        rpidNew =  rpidProtHandler .. aniNew .. rpidRhsTrans

 

 

-- Check if the DNIS equals to the MWI On or Off Number

if dnis == mwiOnNumber then

    -- If DNIS equals to the MWI On Number then return the new Headers

    msg:setRequestUri(ruriNew) -- Return New Request URI

    msg:modifyHeader("To", toNew) -- Return New To Header

    msg:modifyHeader("From", fromNew) -- Return New From Header

    msg:modifyHeader("Contact", contNew) -- Return New Contact Header

    msg:modifyHeader("Remote-Party-ID", rpidNew) -- Return New Remote-Party-ID Header, Only needed when the CUE is connecteed to CUCM through an IP-IP Gateway

elseif dnis == mwiOffNumberNumber then

    -- If DNIS equals to the MWI Off Number then return the new Headers

    msg:setRequestUri(ruriNew) -- Return New Request URI

    msg:modifyHeader("To", toNew) -- Return New To Header

    msg:modifyHeader("From", fromNew) -- Return New From Header

    msg:modifyHeader("Contact", contNew) -- Return New Contact Header

    msg:modifyHeader("Remote-Party-ID", rpidNew) -- Return New Remote-Party-ID Header, Only needed when the CUE is connecteed to CUCM through an IP-IP Gateway

else

    -- If DNIS is something other than the MWI Numbers leave the Headers as is

end

end

return M

 

Regards,

Robert

Sreekanth Narayanan
Cisco Employee
Cisco Employee

That's great! Thanks for sharing your script! I'm sure it'll help others as well.

Jen Zachariason
Level 1
Level 1

Hi Sreekanth,

We are still not seeing the FQDN nmic-ccm-02.noridian.com instead of the IP address.  Please see below logs:

08/10/2015 11:47:53.151  24084       17124 sip_stack               Debug        INFO   - TRANSPORT    -     Remote-Party-ID: "Jen Zachariason" <sip:71632@10.90.2.10>;party=calling;screen=yes;privacy=off
08/10/2015 11:47:53.151  24084       17124 sip_stack               Debug        INFO   - TRANSPORT    -     Contact: <sip:71632@10.90.2.10:5061;transport=tls>
08/10/2015 11:47:53.151  24084       17124 sip_stack               Debug        INFO   - TRANSPORT    -     Max-Forwards: 69
08/10/2015 11:47:53.151  24084       17124 sip_stack               Debug        INFO   - TRANSPORT    -     Content-Type: application/sdp
08/10/2015 11:47:53.151  24084       17124 sip_stack               Debug        INFO   - TRANSPORT    -     Content-Length: 783

using this script:

M = {}
function M.outbound_INVITE(msg)
    local method, ruri, ver = msg:getRequestLine()
    local uri = string.gsub (ruri, '10.90.2.10', 'nmic-ccm-02.noridian.com')
    msg:setRequestUri(uri)
end
return M

_______________________________

Any help would be appriciated.

Thanks,

Jen Zachariason

 

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