1 The new Jitterbuffer in Asterisk
2 --------------------------------
7 The new jitterbuffer, PLC, and the IAX2-integration of the new jitterbuffer
8 have been integrated into Asterisk. The jitterbuffer is generic and work is
9 going on to implement it in SIP/RTP as well.
11 Also, we've added a feature called "trunktimestamps", which adds individual
12 timestamps to trunked frames within a trunk frame.
14 Here's how to use this stuff:
16 1) The new jitterbuffer:
17 ------------------------
18 You must add "jitterbuffer=yes" to either the [general] part of
19 iax.conf, or to a peer or a user. (just like the old jitterbuffer).
20 Also, you can set "maxjitterbuffer=n", which puts a hard-limit on the size of the
21 jitterbuffer of "n milliseconds". It is not necessary to have the new jitterbuffer
22 on both sides of a call; it works on the receive side only.
26 The new jitterbuffer detects packet loss. PLC is done to try to recreate these
27 lost packets in the codec decoding stage, as the encoded audio is translated to slinear.
28 PLC is also used to mask jitterbuffer growth.
30 This facility is enabled by default in iLBC and speex, as it has no additional cost.
31 This facility can be enabled in adpcm, alaw, g726, gsm, lpc10, and ulaw by setting
32 genericplc => true in the [plc] section of codecs.conf.
36 To use this, both sides must be using Asterisk v1.2.
37 Setting "trunktimestamps=yes" in iax.conf will cause your box to send 16-bit timestamps
38 for each trunked frame inside of a trunk frame. This will enable you to use jitterbuffer
39 for an IAX2 trunk, something that was not possible in the old architecture.
41 The other side must also support this functionality, or else, well, bad things will happen.
42 If you don't use trunktimestamps, there's lots of ways the jitterbuffer can get confused because
43 timestamps aren't necessarily sent through the trunk correctly.
45 4) Communication with Asterisk v1.0.x systems
46 ---------------------------------------------
47 You can set up communication with v1.0.x systems with the new jitterbuffer, but
48 you can't use trunks with trunktimestamps in this communication.
50 If you are connecting to an Asterisk server with earlier versions of the software (1.0.x),
51 do not enable both jitterbuffer and trunking for the involved peers/users
52 in order to be able to communicate. Earlier systems will not support trunktimestamps.
54 You may also compile chan_iax2.c without the new jitterbuffer, enabling the old
55 backwards compatible architecture. Look in the source code for instructions.
58 5) Testing and monitoring:
59 --------------------------
60 You can test the effectiveness of PLC and the new jitterbuffer's detection of loss by using
61 the new CLI command "iax2 test losspct <n>". This will simulate n percent packet loss
62 coming _in_ to chan_iax2. You should find that with PLC and the new JB, 10 percent packet
63 loss should lead to just a tiny amount of distortion, while without PLC, it would lead to
64 silent gaps in your audio.
66 "iax2 show netstats" shows you statistics for each iax2 call you have up.
67 The columns are "RTT" which is the round-trip time for the last PING, and then a bunch of s
68 tats for both the local side (what you're receiving), and the remote side (what the other
69 end is telling us they are seeing). The remote stats may not be complete if the remote
70 end isn't using the new jitterbuffer.
73 * Jit: The jitter we have measured (milliseconds)
74 * Del: The maximum delay imposed by the jitterbuffer (milliseconds)
75 * Lost: The number of packets we've detected as lost.
76 * %: The percentage of packets we've detected as lost recently.
77 * Drop: The number of packets we've purposely dropped (to lower latency).
78 * OOO: The number of packets we've received out-of-order
79 * Kpkts: The number of packets we've received / 1000.
84 There's a couple of things that can make calls sound bad using the jitterbuffer:
86 1) The JB and PLC can make your calls sound better, but they can't fix everything.
87 If you lost 10 frames in a row, it can't possibly fix that. It really can't help much
88 more than one or two consecutive frames.
90 2) Bad timestamps: If whatever is generating timestamps to be sent to you generates
91 nonsensical timestamps, it can confuse the jitterbuffer. In particular, discontinuities
92 in timestamps will really upset it: Things like timestamps sequences which go 0, 20, 40,
93 60, 80, 34000, 34020, 34040, 34060... It's going to think you've got about 34 seconds
94 of jitter in this case, etc..
95 The right solution to this is to find out what's causing the sender to send us such nonsense,
96 and fix that. But we should also figure out how to make the receiver more robust in
99 chan_iax2 will actually help fix this a bit if it's more than 3 seconds or so, but at
100 some point we should try to think of a better way to detect this kind of thing and
103 Different clock rates are handled very gracefully though; it will actually deal with a
104 sender sending 20% faster or slower than you expect just fine.
106 3) Really strange network delays: If your network "pauses" for like 5 seconds, and then
107 when it restarts, you are sent some packets that are 5 seconds old, we are going to see
108 that as a lot of jitter. We already throw away up to the worst 20 frames like this,
109 though, and the "maxjitterbuffer" parameter should put a limit on what we do in this case.
111 Reporting possible bugs
112 -----------------------
113 If you do find bad behaviors, here's the information that will help to diagnose this:
117 a) the source of the timestamps and frames: i.e. if they're coming from another chan_iax2 box,
118 a bridged RTP-based channel, an IAX2 softphone, etc..
120 b) The network between, in brief (i.e. the internet, a local lan, etc).
122 c) What is the problem you're seeing.
125 2) Take a look and see what iax2 show netstats is saying about the call, and if it makes sense.
127 3) a tcpdump of the frames, (or, tethereal output from), so we can see the timestamps and delivery
128 times of the frames you're receiving. You can make such a tcpdump with:
130 tcpdump -s 2048 -w /tmp/example.dump udp and port 4569 [and host <other-end>]
132 Report bugs in the Asterisk bugtracker, http://bugs.digium.com.
133 Please read the bug guidelines before you post a bug.