cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1872
Views
5
Helpful
8
Replies

Changing G.729 Millisecond Packet Size for SIP Phones with a normalization script

Nadav
Level 7
Level 7

Hi everyone,

 

I'm running CUCM 11.0 and have tried changing the G.729 Millisecond Packet Size service parameter to 60ms. However looking at the throughput of the RTP between SIP phones, and looking at the SDP messages within the SIP invites, it seems that the attribute is missing and it continues to use 20ms.

 

The bug looks similar to https://bst.cloudapps.cisco.com/bugsearch/bug/CSCuy76761/?rfs=iqvred even though that one is for CUCM 10.5.x 

 

I've tried using https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cucm/sip_tn/9_1_1/sip_t_n/4-sdp_api.html as a reference to add "a=ptime:60"  (there is an example for insertLineAfter) but after applying it to a SIP Profile, and then restarting the phones, the SDP messages still don't include a=ptime:60. Any chance someone can guide me through this?

 

Thanks!

 

This is the script being used:

 

M = {}
function M.outbound_INVITE(msg)
local sdp = msg:getSdp()
if sdp
then
sdp = sdp:insertLineAfter("a=", "G729", "a=ptime:60\r\n")
msg:setSdp(sdp)
end
end
return M

8 Replies 8

Dan Lukes
VIP Alumni
VIP Alumni

Well, I have no experience with CUCM at all, but I need not to have experience to make some notices.

At the first, it seems you are replacing the cause and effect. 'ptime' parameter in SDP claim frame size used by internal RTP engine. You can't just lie here - the ptime announced needs to follow frame size used. No, I don't know how to reconfigure frame size of a protocol on CUCM.

 

It may not be possible for G.729 at all. While I'm unsure about the exact flavor of G.729 you are using (there are various annexes possible), most of variants I know allows fixed frame size only. You are not allowed to use frame size of your choice. I don't know if the CUCM can be forced to violate specifications according yours wishes.

 

Hi, thanks for responding.

If you haven't already, you should take a look at the Bug ID I supplied.
Therein Cisco suggested using a Normalization script for the exact reason
that I need it: the service parameter isn't working correctly.

As for G729, I'm not using any annex.

OK, I claimed I have no experience with CUCM, so it's possible I missed in full. What confuses me is the  Recommendation ITU-T G.729:

The coder operates on speech frames of 10 ms

and

This coder encodes speech and other audio signals with 10 ms frames.

I hope someone more experienced will respond you.

 

See also: voice payload size setting on Cisco 2901 doesn't work

Hi,

 

In my setup all phones are registered to the same CUCM cluster and not to any CUBE. So there aren't any SIP trunks involved.

 

By the way, if there is a working solution other than SIP Normalization then I'm all for it. It's just that since it isn't working correctly for that given Service Parameter that I have to look for a workaround. 

Nadav
Level 7
Level 7

This issue has been replicated in a separate lab for CUCM 11.5. A case is being opened with TAC. I'll keep this post updated. 

 

If anyone has any more insights, I'd be happy to hear it :) 

Hi everyone,

 

It seems like a solution has been supplied via TAC, which allows all G.729 calls within the same cluster to use 10,20,30,40,50 or 60ms packetization between calls. This includes audio conferencing.

 

The solution is a SIP normalization script that has to be applied to the SIP Profile. It runs the same script on Invites and ACKs (necessary for Early-offer). 

 

This script is different than the one supplied earlier as an example from the Cisco documentation. That script could only fix the packetization for one direction of the call. 

Hi Nadav,

 

Can you post here the script?

I need fix packets size on both directions (ptime=20)

Although it's the default value, I receive from public operator packets with size=30ms 

 

Thanks

Sure,

 

Update this thread if it works for you.

 

--[[

    Description: 
        pTime attribute is present in SDP when the call is between SIP Phone to non-SIP device (SCCP phone/H323 gateway/MGCP gateway).
        Sip Phone to SIP trunk/Phone CUCM would not include a pTime attribute in the SDP sent to the phone.
        This script will add a pTime value in the SDP sent to the phone from CUCM when pTime is not present in out bound SDP for G729 codec only.

    Script Parameters:
        
        * The following needs to added while adding/uploading this script to SIP Normalization Script:
            Memory Threshold          : 100 kilobytes
            Lua Instruction Threshold : 2000 instructions

        * The following needs to added in Sip profile page associated with the Sip phone:
            Parameter Name  : G729pTime  
            Parameter Value : 10, 20, 30, 40, 50, or 60 (milliseconds)

            -- * This is mandatory parameter.       
            -- Configure this parameter and make sure this reflects the same value as service parameter “Preferred G.729 Millisecond Packet Size” 
    
    Logic:
        Check if script parameter is configured, if not then no further operations needs to be performed 
        Check if SDP is present in the outbound message, if not then no further operations needs to be performed
        Check if pTime value is valid (one among 10, 20, 30, 40, 50, or 60) , if not then no further operations needs to be performed
        Get the audio mline from SDP
        Check if pTime attribute is already present, if not then no further operations needs to be performed
        Check if there are more than one Audio codec, if there are more than one codec we need not add pTime attribute. 
        Add pTime attribute.              
--]]




M = {}

-- Read the Script Parameters 
local g729ptimeValue = tonumber(scriptParameters.getValue("G729pTime"))


local function addpTimeAttribute(msg)

    -- trace.enable()  
    
    if g729ptimeValue then
        -- if we have value we are good to go
    else 
        -- since there is no Script Parameter we exit this function
        -- trace.format("Script Parameter not configured")
        return
    end
    
    local sdp =  msg:getSdp()
    if sdp
    then
         -- check if the pTime value is valid
         if g729ptimeValue == 60 or g729ptimeValue == 50 or g729ptimeValue == 40 or g729ptimeValue == 30 or g729ptimeValue == 20 or g729ptimeValue == 10  
         then
             -- We have got a valid pTime value
         else
             -- trace.format("Script Parameter ptime is NOT valid")
             return
         end     
         
         -- get audio mline
         local audio = sdp:getMediaDescription("audio")
         if audio
         then

            -- check if we already have ptime
            -- if yes do not proceed
            local ptimeLine = audio:getLine("a=","ptime")
            if ptimeLine then
                -- trace.format("we have ptime do not porceed")
                return
            end

            
            local tokenCount = 0
            -- split the m=audio lines using space as delimiter
            -- for the like below the codecs would start from token 4
            -- m=audio 19800 RTP/SAVP 18 101
            -- if the number of codecs are more than 2 then skip and
            -- do not proceed further
            local audiomLine = audio:getLine("m=","audio")
            for token in string.gmatch(audiomLine, "[^%s]+") do
                tokenCount = tokenCount + 1
                if tokenCount > 5
                then
                    -- we got multiple codecs in SDP hence we need not modify it
                    return
                end                      
            end

            -- we have 2 codecs now need to make sure one is RFC2833
            -- else this a case of multiple audio codecs 
            -- do not proceed.
            local rfc2833_line = audio:getLine("a=","telephone-event")
            if rfc2833_line then
                -- if the 2nd codec is telephone-event then its ok to add the pTime
            else
                -- if the 2nd codec is not telephone-event then this could be a multiple codec case
                -- so return out 
                return
            end                   
            

            
            -- now that we have only one codec with no ptime
            -- go ahead and add ptime value. 
            -- the following api will add the ptime value only if it finds G729

            audio = audio:insertLineAfter("a=", "G729", "a=ptime:" .. g729ptimeValue .. "\r\n")

            sdp = sdp:modifyMediaDescription("audio", audio)
            msg:setSdp(sdp)
         end
    end
end

M.outbound_INVITE      = addpTimeAttribute
M.outbound_ANY_INVITE  = addpTimeAttribute
M.outbound_ACK         = addpTimeAttribute

return M

After adding this normalization script, add it to your SIP profile. Make sure to add the relevant parameter in the SIP profile.