<div dir="ltr">Matt,<div style> First of all, thank you. Thank you for an extensive and thoughtful reply. No question that SLA and CDR together is scary, I discovered that when I first tried to make SLA work for my small (home) environment and scratched my head for many hours trying to come up with a mechanism that would generate a CDR that resembled actual calls. My solution effectively creates two CDRs, one for the channel into the conference, one for the channel out. But I certainly recognize that this violates the purity of CDRs which should have a single CDR for each calling/called party pair. It isn't that Asterisk should be in the billing business, but it should at lest be possible for a billing system to extract accurate start/answer/end times for calls and with SLA it isn't.</div>
<div style><br></div><div style>The answer may well be to reimplement SLA in Asterisk 12 on top of the new services. Certainly current MeetMe implementation is not ideal with nasties like tight loops polling for status changes. I think the dust needs to settle on Asterisk 12 and them maybe someone can take a look at that as a project.</div>
<div style><br></div><div style>Most of the changes in the patch I uploaded are confined entirely to the SLAStation() code path, but there are some inside the core MeetMe conference which will trigger if a masquerade takes place -- which may be a side effect with unintended consequences that you feer. I will not be offended if you elect to leave things as they stand (but do see my comments in the code regarding locking the channel, I think I found a condition where MeetMe should have locked the channel first but didn't, irrespective of me messing with the CDR on the channel).</div>
<div style><br></div><div style>Thank you,</div><div style>David</div><div style> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 12, 2013 at 4:23 PM, Matthew Jordan <span dir="ltr"><<a href="mailto:mjordan@digium.com" target="_blank">mjordan@digium.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 03/12/2013 01:11 PM, David Kerr wrote:> Matt,<br>
<div class="im">> If you are messing with CDRs please take a look at bug id 20747 and<br>
> the corresponding fix I posted to reviewboard (which has received no<br>
> comments). CDRs are not accurately recorded for outbound calls that go<br>
> through SLA. I understand the reasons why it is broken and partly it is<br>
> to do with the implementation of SLA and partly it is just the nature of<br>
> what SLA is in the first place. I would very much like some review of<br>
> this bug id and the fix on reviewboard.<br>
<br>
</div>The reason why no one has commented is because the patch is scary: SLA<br>
and CDRs!<br>
<br>
Yikes. :-)<br>
<br>
I'll try to take a look at it on Thursday (our typical code review day),<br>
but I have a feeling that it's going to have a lot of side effects that<br>
are dangerous. Modifying CDRs in the the existing code base tends to<br>
have that effect, no matter how hard anyone tries. This is part of the<br>
reason why we have the "policy" to never alter CDR behavior in release<br>
branches.<br>
<br>
In reality, in the existing code base, the behavior of CDRs is not<br>
defined for SLA - or really, for any multi-party scenario. While I'm<br>
sure that feels like a bug, we've arrived there after many failed bug<br>
fixes that only exacerbated problems. CEL was born of those efforts. The<br>
only reason we are able to partially deal with multi-party scenarios in<br>
Asterisk 12 is due to the Bridging Framework and Stasis-Core, as I'll<br>
get to later.<br>
<div class="im"><br>
> But for your CDR spec for Asterisk 12, you should at least document how<br>
> it should work for extension(s) and trunk configured as SLA. There are<br>
> multiple scenarios...<br>
<br>
</div>So, thanks for reading the specification and providing feedback.<br>
Unfortunately, most of this e-mail is going to be bad news.<br>
<br>
Let's just start at the root of it: I didn't forget SLA. I explicitly<br>
chose not to define the behavior for the current implementation of SLA.<br>
<br>
Why not?<br>
<br>
First, understand that the only reason we are looking at CDRs is because<br>
we are forcing ourselves to. The migration of bridging to the Bridging<br>
Framework necessitates updating of CDRs, as a lot of CDR behavior is<br>
defined in masquerade callbacks and the bridging loops. Those<br>
masquerades are now not going to occur as often, and the bridging loops<br>
are going to get deleted wholesale. That means we either have to discard<br>
CDRs completely, re-implement the logic in the Bridging Framework, or<br>
find another way to disseminate Channel/Bridge information to the CDR<br>
engine.<br>
<br>
We're choosing the last option. Right now, however, the Bridging<br>
Framework's threading model is undergoing changes by Richard (see the<br>
bridge_construction branch) and Stasis-Core is getting implemented in<br>
trunk (as well as a variety of other team branches). It's all still very<br>
much a work in progress.<br>
<br>
The idea however, goes as follows:<br>
<br>
The Bridging Framework changes the nature of bridges in Asterisk by<br>
promoting them to a first class object. You no longer have a collection<br>
of channels in some shared state; you have a collection of channels<br>
owned and managed by a well defined object. The difference is subtle,<br>
but important: by having an object with its own state, we can naturally<br>
track the lifetime of communication paths between channels. The fact<br>
that transfers will (with very few exceptions) exist solely between<br>
channels in bridges helps us to define the behavior of CDRs for those<br>
scenarios. More importantly, Stasis-Core provides a means to disseminate<br>
this state information through Asterisk as well as cache it. This lets<br>
the CDR engine be built independently of the objects it tracks - so now<br>
where CDRs previously had to live on a specific channel, they can simply<br>
be their own entity tracking channels in bridges.<br>
<br>
As such, without both the Bridging Framework and Stasis-Core together, I<br>
would not touch CDRs. Even with both these components, this project is<br>
going to be challenging.<br>
<br>
So where does SLA fall short?<br>
<br>
1) It is built on MeetMe, not the Bridging Framework. As such, it does<br>
not have the same cohesive view of a Bridge and its Channels that Stasis<br>
Core is relying on.<br>
2) Its view of Bridging is unique. Unlike most other bridging concepts,<br>
it relies upon channel roles extensively (station/trunk). This<br>
complicates CDRs, as you allude to later.<br>
3) We (as in the Asterisk developers here at Digium) are not migrating<br>
SLA under the Bridging Framework for Asterisk 12. While this is doable -<br>
and certainly a project to be encouraged - it is outside of the scope of<br>
work that we have engineering resources for. Obviously folks in the<br>
developer community could take that project on, in which case my next<br>
point wouldn't be valid.<br>
4) I'm not defining the behavior for things we aren't attempting to<br>
tackle for Asterisk 12. Doing so would be disingenuous to Asterisk Users.<br>
<br>
I understand that this is frustrating: it isn't fun to have a feature in<br>
Asterisk that you use but doesn't receive a lot of attention. More on<br>
possible avenues below.<br>
<div class="im"><br>
> Party A connects to Asterisk SLA (hears a dialtone) and dials Party B<br>
> (which connects or does not answer). Dialtone comes from either analog<br>
> trunk or DISA() Asterisk application.<br>
> Party A dials Party B (no intermediate dialtone from Asterisk, just<br>
> "direct" through SLA "conference" to Party B<br>
> Party A dials Party B (either of above two scenarios). Party C joins in<br>
> by pressing SLA trunk button on phone. Three way conference takes place.<br>
> Party C hangs up. Party A later hangs up.<br>
> Party A dials Party B. Party C joins in by pressing SLA trunk button on<br>
> phone. Three way conference takes place. Party A hangs up. Party C<br>
> later hangs up.<br>
> Last two scenarios with a Party D, E, F etc. joining and leaving.<br>
<br>
</div>Unfortunately, this is most likely already too complex. I'd take a<br>
slightly different approach.<br>
<br>
If I were to attempt to define the behavior (which I'm not), I would<br>
attempt to boil it down to the simplest way of "viewing" the SLA use<br>
case. For SLA, that's periods of communication between trunks on one<br>
hand, and stations on the other. While that requires the CDR code to<br>
have some concept of channel role and bridge type, that's not terrible<br>
(we're going to have to do something similar with Parking).<br>
<br>
This means that if you have a call come in from a trunk, and station A<br>
answers it, you have one CDR. If station B also picks up the line, you<br>
have two CDRs. Each CDR represents a path of communication between a<br>
trunk and a station - so one for trunk -> A and one for trunk -> B.<br>
<br>
Directionality shouldn't matter here: if A places a call out a trunk and<br>
B barges in, there are still two CDRs (although the Party A may differ,<br>
depending on the configuration). Whether or not trunks are always Party<br>
A, stations are Party A, or the oldest is Party A should probably be<br>
left up to the dialplan.<br>
<br>
Alternatively, you could simplify this further and simply treat SLA as<br>
one big multi-party bridge, and use the existing multi-party approach in<br>
the CDR specification. This would be the easiest way to handle SLA, and<br>
would defer the majority of billing logic to where it belongs: billing<br>
engines.<br>
<div class="im"><br>
> And there may be other scenarios as well. In Asterisk 1.8 and 11 the<br>
> CDR for Party A is frequently wrong... For example, in the first<br>
> scenario Party A CDR is "answered" when receiving the dialtone (entering<br>
> the SLA conference) not when Party B answers. And in many cases when<br>
> Party B answers a bridge/masquerade takes place that "ends" the CDR.<br>
><br>
> The Asterisk 12 CDR spec should document expected behavior for SLA. For<br>
> example, should even the simplest of SLA calls generate two CDR<br>
> records... one from Party A to SLA "conference" the other from the SLA<br>
> conference to Party B. This may sound strange, but when you have a<br>
> Party C, D, E potentially joining and leaving the conference it may be<br>
> the only way to accurately keep track of billing seconds.... and in the<br>
> dialplan you can make use of NoCDR() etc. to control which records you<br>
> actually want.<br>
><br>
<br>
</div>Well, I'm sure CDRs for SLA don't make much sense in the release<br>
branches. I'm fairly confident that they were never intended to make<br>
much sense.<br>
<br>
However, I think you might be taking a slightly dangerous approach to<br>
this problem. Attempting to make SLA a 'channel' in a CDR breaks the<br>
general view CDRs have of the world. I would approach SLA as if it were<br>
a bridge, not an application or a channel state in and of itself. The<br>
endpoints involved should be the entities represented in the CDR - that<br>
means the trunks and stations.<br>
<br>
Finally, I would avoid trying to make Asterisk be in the business of<br>
making billing decisions. I'd go so far as to say that NoCDR is an evil<br>
that I'd prefer to delete but, unfortunately, probably can't. (If<br>
nothing else, there's only so many times I can apologize for breaking<br>
people's dialplans in a single day.) Asterisk should report the details<br>
of communication between endpoints, but should defer billing problems to<br>
a billing analysis engine. Billing engines should make the billing<br>
business decisions, and they will be far better at it than Asterisk will be.<br>
<br>
So, all of this being said, there are ways in which SLA can have CDR<br>
behavior defined for it in Asterisk 12.<br>
1) Ideally, someone would move SLA under the Bridging Framework. This is<br>
a non-trivial project, but by doing so they will automatically gain<br>
whatever Stasis-Core events exist under the framework. The updates to<br>
the CDR engine to accomodate the bridge type and the channel roles won't<br>
be simple, but would not be terribly difficult.<br>
2) Less ideal, the Stasis-Core events could be replicated in the<br>
existing SLA code. This is a temporary solution as it does not actually<br>
move SLA under the common framework - thereby duplicating functionality<br>
and creating complexity in the existing SLA code - but may be easier for<br>
someone to approach.<br>
<br>
However, I don't want to update the specification with behavior for SLA<br>
unless someone is actually going to commit to doing the work for<br>
Asterisk 12. Without someone taking on that project, there's no way to<br>
commit to CDR behavior for it, and unfortunately, we aren't going to<br>
have the bandwidth to tackle SLA ourselves.<br>
<br>
Matt<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Matthew Jordan<br>
Digium, Inc. | Engineering Manager<br>
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA<br>
Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> & <a href="http://asterisk.org" target="_blank">http://asterisk.org</a><br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
<br>
asterisk-dev mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-dev" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>
</div></div></blockquote></div><br></div>