Modem testing with Asterisk
I had a little problem at work last week: I needed to test a dial-in modem, but I didn’t have a pair of phone lines to use for testing. Our rented office space comes with a PBX, but they’d probably charge us a couple hundred bucks to wire up a pair of analog ports for us, and then take a week or two to do it. Alternately, there’s a bunch of stuff on the market that you can buy for this sort of testing, but considering what it costs, it’s kind of pointless for us.
Instead of doing that, I was able to rig up a testing system using Asterisk and a bit of equipment that we had sitting in the lab: a Cisco 3640 with a 2-port FXS VIC. Going into this, I wasn’t sure how long it’d take–I’d never set up voice services on any Cisco devices before, so I wasn’t sure how big of a pain it’d be. I figured it’d take me most of a day to get it set up and working. As it turned out, the first phase of the project, setting up Asterisk and the Cisco, only took a hour. Installing Asterisk 1.0-RC2 only took a few minutes, and configuring the Cisco to talk to Asterisk was fairly painless. I didn’t have a test phone (or even a modem) handy yet, but I was able to use X-Lite to call Asterisk and watch the phones ring on the Cisco.
The second phase was supposed to be easier: wiring up a serial modem to a test device, and then plugging my laptop and the serial modem into the 3640. And that’s where everything fell down. While I could dial into the Cisco FXS ports without problems, I couldn’t dial out from them. In fact, I couldn’t even get the ports to go off-hook–the Cisco never even noticed that I’d picked up the phone. After reading half of cisco.com, I concluded that the IOS version that we were using must just have been broken and upgraded to a newer release. And that was all it took–everything worked perfectly as soon as the 3640 finished rebooting.
For reference, here are the Cisco config snippets that I needed on the 3640. The two FXS ports are 1/0/0
and 1/0/1
. I’m calling them extension 3001
and 3002
. Here’s the config:
voice-port 1/0/0
signal groundStart
station-id name PORT 1
station-id number 3001
!
voice-port 1/0/1
signal groundStart
station-id name PORT 2
station-id number 3002
!
dial-peer voice 1 voip
destination-pattern ....
session protocol sipv2
session target sip-server
codec g711ulaw bytes 80
!
dial-peer voice 2 pots
destination-pattern 3001
port 1/0/0
!
dial-peer voice 3 pots
destination-pattern 3002
port 1/0/1
!
sip-ua
retry invite 3
retry cancel 2
sip-server ipv4:10.0.0.1:5060
!
Here’s the Cisco part of Asterisk’s sip.conf
:
[3001]
type=friend
username=3001
host=10.0.0.2
context=intern
canreinvite=yes
dtmfmode=inband
qualify=1000
[3002]
type=friend
username=3002
host=10.0.0.2
context=intern
canreinvite=yes
dtmfmode=inband
qualify=1000
And finally Asterisk’s extensions.conf
:
[intern]
exten => 3001,1,Dial(Sip/3001)
exten => 3002,1,Dial(Sip/3002)
exten => 3003,1,Dial(Sip/3003)
exten => 3004,1,VoiceMail(3004)
exten => 3005,1,VoiceMailMain(s3004)