<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2176/18/9/_/styles/combined.css?spaceKey=AST&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=DirectMediaGlare|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: 983px;"
usemap="#gliffy-map-21757961-1877"
src="/wiki/download/attachments/21463142/DirectMediaGlare.png?version=1&modificationDate=1346271744443"
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>
<table width="100%">
<tr>
<td align="left" >
<table>
<caption align="bottom">
</caption>
<tr>
<td>
<img style="border: none; width: 716px;"
usemap="#gliffy-map-21757959-5813"
src="/wiki/download/attachments/21463142/DirectMediaOneServer.png?version=2&modificationDate=1346270162824"
alt=""/>
</td>
</tr>
</table>
</td>
</tr>
</table>
<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, the downstream Asterisk server will attempt its reinvite again and succeed this time. A diagram of this situation looks like this:</p>
<table width="100%">
<tr>
<td align="left" >
<table>
<caption align="bottom">
</caption>
<tr>
<td>
<img style="border: none; width: 983px;"
usemap="#gliffy-map-21757955-7217"
src="/wiki/download/attachments/21463142/DirectMediaOneServer.png?version=3&modificationDate=1346271237972"
alt=""/>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>The problematic area is higlighted in red. While this eventually results in direct media flowing between the endpoints, the delay between the 491 responses and the re-attempt at reinviting the media may be noticeable to the end user. If more than two Asterisk servers are in the path between callers, this delay can be longer. 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 the second diagram 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 to send if the RTP layer requests it again. Here is a diagram showing how this works if Asterisk 2 has <tt>directmedia = outgoing</tt> set:</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=8&originalVersion=7">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>