<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/18/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance">SIP Direct Media Reinvite Glare Avoidance</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~mmichelson">Mark Michelson</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{gliffy:name=DirectMediaOneServer|align=left|size=L|version=1} <br></td></tr>
            <tr><td class="diff-unchanged" >{warning} <br>This page is a work in progress. Please refrain from making comments on this page until this warning is removed. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        


<table width="100%">
    <tr>
        <td  align="left" >
            <table>
                <caption align="bottom">
                                    </caption>
                <tr>
                    <td>
                        <img style="border: none; width: 716px;"
                                                          usemap="#gliffy-map-21757955-4763"
                                                          src="/wiki/download/attachments/21463142/DirectMediaOneServer.png?version=1&amp;modificationDate=1346270153744"
                             alt=""/>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>



<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This page is a work in progress. Please refrain from making comments on this page until this warning is removed.</td></tr></table></div>

<h1><a name="SIPDirectMediaReinviteGlareAvoidance-Overview"></a>Overview</h1>

<p>When SIP endpoints communicate by way of Asterisk, Asterisk will attempt to send SIP reinvites in order to allow the endpoints to communicate directly. This allows for the computational load on the Asterisk server to be decreased while also lessening the latency of the media streams between the endpoints. A typical situation might look like this: </p>

<p>When multiple Asterisk servers exist between the endpoints, then both Asterisk servers will attempt to send direct media reinvites. If it happens to be that the two Asterisk servers direct their reinvites to each other at the same time, then each of the Asterisk servers will respond to the reinvites with 491 responses. After a delay, then the Asterisk servers will attempt their reinvites again, this time succeeding. A diagram of this situation looks like this:</p>

<p>While this eventually results in direct media between the endpoints, the delay between the 491 responses and the re-attempt at reinviting the media may be noticeable to the end user. In Asterisk 11, a new option has been added to chan_sip in an attempt to address this.</p>

<h1><a name="SIPDirectMediaReinviteGlareAvoidance-%7B%7Bdirectmedia%3Doutgoing%7D%7D"></a><tt>directmedia = outgoing</tt></h1>

<p>The problem in Figure 2 was that both Asterisk servers assumed control of the path between them. In reality, it is only required that one of the Asterisk servers does this. This is where the <tt>directmedia = outgoing</tt> setting becomes useful.</p>

<p>The way this option works is when the SIP channel driver is told by the RTP layer to send a direct media reinvite out, we check to see if the directmedia setting is set to outgoing for the dialog. If it is, and the call direction is not outgoing, then we will refrain from sending a reinvite. After this first denial to send the direct media reinvite, we will no longer refuse if asked.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=21463142&revisedVersion=2&originalVersion=1">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>