NCS 416 Paul Brennan Mohammed Haque IAX2 Trunking
Abstract This project explores setting up a server to interface between the PSTN and multiple Asterisk PBX systems. The server interfaces with the PSTN with a set of analog Digium FXO cards, one 4 port and 8 port. The server interfaces with the PBX systems through the IAX2 protocol, or the Inter-Asterisk Exchange protocol, Version 2. The server itself runs the AsteriskNOW distribution, which installs the Asterisk PBX service and the FreePBX management interface. Through this interface, we set up not only the trunks, but also a set of rules to route calls through the system to the various trunks. The IAX2 trunks could route in either direction, but the analog cards could only call out due to the dial out only lines provided by SUNYIT. After setup and configuration, the system was demoed to a class of telephony students, who were able to connect to and utilize the server with the help of our documentation. Introduction These days setting up a PBX server for your school, place of business, or home is relatively cheap. You can set up a PBX server using Asterisk on virtually any machine, or even on a virtual machine. Setting up your own PBX server opens up a world of possibilities in telephony, and can even save you money over traditional PBXs. The AsteriskNow distribution, built on top of CentOS, can deliver Asterisk and FreePBX, making an easy to use and powerful environment. For some, the biggest reason to implement this system may be cost, since this free software can run on relatively cheap hardware. Since Asterisk harnesses the power of VoIP, you can use the existing data network to set up hard and soft phones. A few lines from the phone company can be shared across an entire company, while your PBX handles all internal calls. The flexibility allows you near endless possibilities, such as set up hunt groups dial a whole department with a single number. With your own PBX server, there isn t really a limit on how many extensions you can set up, or what you can do with those extensions. Arguably the most important tool is the ability to set up trunks, which to allow you to connect to different telephone networks and PBX servers. These trunks enable multiple call to be routed to and from outside networks simultaneously, and really increase the practicality of an Asterisk system.
Procedure Setting up AsteriskNow is as easy as burning an ISO to a disc and popping it into a computer. Once the disc is in the computer, boot up and follow the easy to understand direction. The install goes over simple things like setting up your keyboard layout, setting up your timezone, choosing how to partition your disk, and creating a root password. After rebooting, there was still some tweaking we had to do. For security reasons, we set up separate user and root accounts for each of us, and disabled root logins over SSH. We configured the network settings, assigning a static address of 10.107.6.11, as to not conflict with an old trunk server set up at 10.107.6.10. We also hooked up the to a network KVM, since it was mounted on a rack enclosure. However, this KVM was quite buggy, so we used SSH or the web interface as much as possible. Setting up trunks allowed our server to connect to the roughly 20 PBXs in the class, as well as the campus POTS. A trunk provides a shared connection to another server or network, and allows for inbound and outbound calls to the outside world, and its not too hard to set one up. A trunk is essentially a bundle of connections, and allows multiple calls to routed to outside the PBX. When setting up a trunk, Asterisk provides a few options: a) SIP Trunk b) DAHDI Trunk c) Zap Trunk d) IAX2 TRUNK e) ENUM Trunk f) DUNDI Trunk Our project mostly be explored IAX2 and Zap (DAHDI compatibility), and we will go in depth
into the advantages and disadvantages of IAX2, as well as its basic function. After the initial setup, we configure both IAX2 and the FXO ports. IAX2 is a VoIP protocol that allows the Asterisk servers to interconnect, in this case allowing the virtual machines set up by the students in the class to talk to each other. IAX2 will need to be configured on both sides of the trunk connection. Because of this, all Asterisk machines connecting to the trunk will need to be registered to allow connections to be established, and facilitate the proper routing of calls. Both machines connected to the trunk must have the IP address of the other, as well as an account set up to authenticate the connection. In testing, the two of us were able to test the IAX2 trunks to our PBXs with no issues. When it came time to set up the student's trunks, we used DNS records to point to the second IP each student's assigned range. For the purposes of the class, we assigned each student a number, 1-22, and used those numbers in trunk and route names. We set up the trunk server's side of the connection, and informed the student's of the connection convention they were to use. If the students correctly utilize the scheme we set up, they should be able to send and receive calls between extensions on each of our PBXs. IAX2 offers several advantages over other VoIP protocols when it comes to trunking. With IAX2, signaling and voice can be sent over the same connection (RFC 5456). It accomplishes this by setting a reliability flag when signaling information is sent, which changes the header slightly and enforces reliable transfer on the application layer. When that flag is set, sequence numbers are used to ensure no loss, much like in TCP, although the packet is still transmitted via UDP. When the flag is not set, and voice is being transmitted, timestamps are used to drop out of order packets, much like in RTP. Other protocols, such as SIP, merely negotiate a RTP connection between endpoints. However, IAX2 performs all communication over a single UDP connection, which has the added benefit of allowing for easy transition across
NATs. In fact, IAX2 can even concatenate multiple voice packets into one trunk packet, cutting down network overhead by eliminating redundant headers. All this makes it the ideal protocol for connecting the Asterisk boxes. As for the interface with the PSTN, the server is equipped with 12 FXO ports, or Foreign exchange Office ports. These ports connect to FXO wall ports, and essentially allow the server to act like a telephone, as it can detect a ring, and send on and off hook signals back to the PSTN, and listen or broadcast sounds across the line. The server can be set up to listen for a ring, in which case it could forward the call to based on some predefined rule, such listen for further DTMF signals to forward the call. However, our connection to the campus POTS allowed us to only dial out, but this allowed for phones connected to the trunk server (through their local Asterisk PBX) to connect to the PSTN. To ensure the lines were working, we tested their connection with a standard phone. At first it seemed that all the provided lines were dead, but it turned out we were using a digital phone (although not a VoIP phone...), the kind used in many offices. When we retested with a standard analog phone, we found all but one line worked. There was also the small issue of cord length. At first the server had been racked, but after we noticed the cords were to short to connect the server to the phone jacks, we had to de-rack the server and move to closer to the jacks. We also had some issues getting one of the Digium cards to register, and after some troubleshooting, moving it to a different PCI slot solved the issue. Once the ports had been recognized through DAHDI (Digium/Asterisk Hardware Device Interface), we had to do something with them. We put all the active ports into a group, and then set up a trunk to use that group. This part took a bit of trial and error to figure out, but once we did it worked like a charm. When a call was placed to that trunk, it would cycle through the group until it found an open line, and it would then dial out across that line. That brings us to the next step, routes. Trunks simply set up connections, routes allow those connections to be used.
In testing, we set up routes on our class PBXs to forward calls of a certain pattern to the trunk server. Once the call reached the trunk server, it was matched to a rule that forwarded it to the other PBX. Through this system of forwarding, a call from a phone connected to one PBX could call a phone connected to the other PBX. We were able to accomplish this with relative ease, as it was easy to coordinate on this small scale. To make calls across the DAHDI trunk, a route was set up with three patterns to match to. To dial an on campus number, the pattern 7XXX was used. To dial off campus, the 7-digit pattern was used, with the addition of 8 used to escape the campus network. The rule would prepend an 8 to standard 7-digit numbers, and would accept numbers that had already prepended an 8. With these rules in place, Paul was able to call both Nick Merante's office and Ronny's cell phone. Calling a student's PBX was a bit trickier. We decided using a scheme similar to the campus's escape digit would work. Each student was assigned a three digit code, ranging from 101-122. The server would match any number that began with one of these codes, strip the code with a prefix, and call the remaining destination number on the associated trunk. For example, to call extension 3000 on student-01's PBX, the server would match on the destination 101-3000, and call 3000 on the trunk for student-01. With this new scheme, student's could set up routes on their own machines that either match numbers beginning with that range, or use some other escape code to send a number to the trunk server to be processed. To wrap up the project, after everything was set up and tested, we produced a lab explaining briefly how the system works and how the students are to connect to and use it. As long as the student's follow the conventions set up for them, which were outlined in the lab, then it should be a rather straight forward lab for them to complete.
Conclusion Overall, this project was not too difficult from start to finish. There were a few hiccups, but setting up simple trunks and routes was rather easy. Deciding on conventions to bring the project up to the classroom scale took some thought, but implementing it was mostly just tedious. The last set of issues we had were installing new FXO cards into our physical servers which Paul took care of. After that, all we had to do is come up with the lab portion, which was not too difficult. This project was more than a project because it provided us with a real world experience on how to set up a trunk. Initially, it sounded a bit difficult and wasn t sure where to start but as the project progressed, it became much simpler. By understanding how a trunk works, how to setup a trunk, advantages and disadvantages of different trunking protocol, you are able to better manage and set up an entire phone system if you needed to. Setting up routes within the trunk allowed us to view Asterisk as more than just a system for local connections, but as switch within a larger network. It began to put things in perspective, and let us see how both peer and hierarchical networks could be set on any scale. With the flexibility and cost of Asterisk, it is clear why VoIP is becoming an increasingly cheap yet powerful solution. This was a great topic, a good project that has a real world application.
Works Cited Spencer, Mark. "IAX: Inter-Asterisk EXchange Version 2." Rfc-editor.org. N.p., Feb. 2010. Web. 20 Nov. 2012. <http://www.rfc-editor.org/rfc/rfc5456.txt>. Madsen, Leif, Jim Van. Meggelen, and Russell Bryant. Asterisk: The Definitive Guide. Sebastopol, CA: O'Reilly Media, 2011. Print. Spencer, Mark. "IAX versus SIP." Voip-Info. N.p., 5 July 2004. Web. <http://www.voip-info.org/wiki/view/iax+versus+sip>. "PBX in a Flash for Newbies." Connecting Two Asterisk PBX Servers Using an IAX2 Trunk -. N.p., n.d. Web. 15 Nov. 2012. <http://www.cadvision.com/blanchas/asterisk/iax2trunk.html>. "Asterisk Config Iax.conf." - Voip-info.org. N.p., n.d. Web. 15 Nov. 2012. <http://www.voip-info.org/wiki/view/asterisk config iax.conf>. "IAX." - Voip-info.org. N.p., n.d. Web. 16 Nov. 2012. <http://www.voip-info.org/wiki/view/iax>.