29 Mar 2006 10:18

Prepend the Area Code with Asterisk

If you want to prefix the area code for 7-digit numbers with Asterisk, it usually looks like something like this:

ext => _NXXXXXX,1,goto(505${EXTEN},1)

But if you need to server all area codes dynamically, you can do something like this:

ext => _NXXXXXX,1,goto(${CALLERID(number):0:3}${EXTEN},1)

This assumes caller id is set, and that your callers are using standard PSTN-like DIDs.

04 Feb 2006 10:52

Only use_media_proxy once

If you ever see strange sdp content like the following:

...
c=IN IP4 68.142.145.14568.142.145.145
...
m=audio 3501835018 RTP/AVP 0 8 3 98 97 101
...

That is, the IP address and port are repeated back to back (which really throws off the far end), and you are using openser and mediaproxy, then you are probably calling use_media_proxy twice in your ser routing. Apparently, this is a bad idea.

20 Jan 2006 12:03

Using iptables to set ToS

X-Lite and Twinkle don't have a way to set ToS. So let's get iptables to do it:

iptables -A POSTROUTING -t mangle -p udp -m udp --sport 8000:8009 \
    -j DSCP --set-dscp 0x2e

That sets the DSCP for UDP packets with a source port of 8000-8009 to 0x2e, which is the Expedited Forwarding PHB. You'll need to pick a range that works for you. Both X-Lite and Twinkle use 8000 as a default, so that's what this rule says.

20 Jan 2006 08:31

0xb8

So I learned this morning that ToS is old-school. According to RFC 2474 we now have the Differentiated Services Field. I came to this realization as I was looking for the ToS bits in Ethereal, which decodes that octet as the Differentiated Services Code Point (DSCP). I found this great article on Precedence and DSCP which explains both ToS and the newer DS Field very well. Go ahead, we'll wait for you to read it.

RFC 2598 defines the Expedited Forwarding PHB, which is what "most" VOIP implementations use, supposedly. The DSCP for Expedited Forwarding is 0x2e. However, the whole octet includes the two unused bits, so left shift twice and you get 0xb8. This is the magic number to use in Asterisk:

; sip.conf and/or iax.conf
[general]
tos=0xb8 ; Expedited Forwarding DSCP

You'll need to restart Asterisk in order for this to take effect; reload is not sufficient.

The Expedited Forwarding DSCP is backwards-compatible with the old ToS field. It breaks down to precedence 5 and the low delay and throughput fields set.

I was rather surprised and disappointed to learn neither that X-Lite, which I use on my iBook, nor Twinkle, which I use in Linux, seem to have any way to set the ToS field, and just use 0x0. If you know how to set ToS on either of those programs I'd sure like to hear it.

21 Nov 2005 19:57

Gizmo

I ran across the Gizmo Project today. It warms my heart. Now that I have cultivated your curiousity, Gizmo is what Skype should have been. In other words, Gizmo is Skype with standard open protocols. (SIP, to be specific)

It was easy to set up Asterisk, and I have bidirectional Asterisk-to-Gizmo communications. The one caveat is that I can't seem to call my Asterisk box from my Asterisk box via Gizmo. I'm not sure why that is, but aside from testing that wouldn't be all that useful so I'm ok with it.

My only complaint is some clown stole the username I prefer. So, on Gizmo I guess I go by hans_fugal (17476265435). Give me a call! Or, at least, give my monkeys a call.

05 Sep 2005 10:11

The Wonder Shaper

When we moved to Las Cruces I ditched Qwest for telephone service, and went with standalone DSL, Asterisk, and NuFone for my phone service. The other day someone was downloading stuff from my website, using all my upload bandwidth, and my wife was trying to talk to someone on the phone. Although she could hear them just fine, they couldn't hear a thing she said because she was breaking up so bad. Thus began my quest for QoS.

Actually, I had downloaded and set up a script to do QoS that I got from the wiki, and I forgot to reconfigure it to my current bandwidth. So ironically, undoing what that script did helped just because it let me use all of my bandwidth. Then I tried to adapt the script to my current situation, and found that it didn't really work. So I went to the lartc and read up on Queueing Disciplines and tried to make my own VOIP QoS script. I spent hours on this, and although I gained a pretty good understanding of it all I never did get a script that worked well. It kind of worked, but not well enough.

This morning, I stumbled across the Wonder Shaper and decided to give it a try. If it didn't work well for VOIP at least I'd have a starting point for modifications. The results were truly wonderful. I was able to carry on a normal conversation with my mother while uploading an ISO with scp to my ISP.

The added bonus of having really great performance for other interactive applications such as ssh has really sold me on the Wonder Shaper. Even if you don't do VOIP, you should give it a try. If you have a recent kernel it's so easy to use, and has such great returns, that you would be foolish not to.

05 Aug 2005 08:43

NuFone Outgong Call Woes

NuFone is my VOIP provider of choice, but I had a devil of a time being able to call out from my Sipura SPA-1001, through Asterisk, to NuFone. It turns out the problem was Caller ID. When I set my sipura's extension to 42 instead of sipura, I was able to dial out, but the CID said simply 42. Well that is kind of cool, and demonstrates that the reason NuFone's Asterisk (or PSTN connection) was rejecting my call is that I had invalid Caller ID for the number ("sipura"), but I would like to be a good phone system citizen. Junction Networks, of whom I had never before heard until google matched us up, has the answer. So I added that SetCIDNum call and things are working great.