Encyclopedia Knowledge

December 29, 2006

[linux] Make file tutorials

Filed under: C Programming — encyclopedia @ 4:28 am

Moi nguoi doc huong dan ve makefile cho gcc.

http://www.cs.utah.edu/dept/old/texinfo/make/make_toc.html#SEC1

http://www.eng.hawaii.edu/Tutor/Make/
http://www.student.cs.uwaterloo.ca/~isg/res/unix/make/tutorial/
http://mrbook.org/tutorials/make/

Link e tu tim them:

-L: http://web51.hw-server.com/user_descript.html

http://www.gnu.org/software/make/manual/html_node/index.html

CFLAGS
Extra flags to give to the C compiler.
 
CFLAGS is used for the flags to the C compiler. Thus setting CFLAGS to “-g -Wall” will compile all programs with debugging (-g) and with all warnings enabled (-Wall). Environment variables can be defined in make by using “VARIABLE=value” for example:

CFLAGS=-g -Wall; CFLAGS += -g -ggdb; CFLAGS += -fpic;
CFLAGS = -Wall -ggdb -fPIC $(DFLAGS) ;
dddd

[asterisk] Kinh nghiệm làm việc với AMI

Filed under: VOIP News — encyclopedia @ 4:24 am

Làm việc với manager API và các hạn chế của nó

Lời tác giả:
“After battling with the Asterisk Manager interface(and getting it to pretty much do everything I want to do with it) I thought I’d share my experiences with those who are developing or are thinking of developing applications using it.”

Đầu tiên là một số thứ mà Manager cho phép bạn thực hiện:

* Thực hiện một cuộc gọi từ bất cứ extension/resource nào đến bất cứ một extension/resource nào khác. Ví dụ:

* từ một sip phone đến một zap line bên ngoài
* từ một extension number đến một iax extension bên ngoài
* từ trong một meetme room đến một zap channel
* Chuyển cuộc gọi (Redirect) BẤT CỨ cuộc gọi đang có nào (live call) đến BẤT CỨ đích nào khác, ví dụ:
o chuyển một [live] SIP call từ bất cứ đâu và gửi đến một meetme room
o chuyển một zap call từ một meetme room và gửi đến một extension
o chuyển BẤT CỨ cuộc gọi nào đến một Zap channel bên ngoài
o như một phương pháp thay thế cho parking, giữ một cuộc gọi bằng một âm thanh nền dài (background sound file) hay MoH (music on Hold) và lấy lại cuộc gọi sau đó bằng cách chuyển tiếp their channel đến đâu đó
* Hangup bất cứ live channel whether it be SIP, Zap, IAX, H323, etc…
* Hangup các channels riêng lẻ trong một meetme conference
* Initiate a recording (and stop it too) of any live Zap channel at any time(with custom filename)
* Get the status of voicemail in any mailbox
* Get the status of an extension
* – Get data from commands such as “show channels”
* Get data on Queues
* Get data on IAX peers

Thứ hai, đây là một số điều bạn fải biết nếu định viết chương trình về manager interface:

* Manager API is not well documented(Yes I know I need to add my notes to the wiki)
* All connected terminals will receive all “Events” that happen on the Asterisk box
* Không fải tất cả các Asterisk commands sẽ được chấp nhận trong “Action: Command” action
* Disconnecting the connection between a remote connected terminal and the Asterisk box will often cause a deadlock (http://bugs.digium.com/bug_view_page.php?bug_id=0000861) <<<–This bug has been reported fixed on 2-07-2004
* Any form of freeze on the connected terminal will cause a buffer overflow and will also deadlock Asterisk
* “Status” Actions can yield upto a hundred lines of output depending on how busy your Asterisk machine is.
* “Ping” and “Show uptime” may not return results in some applications(like perl Net::Telnet)
* với các ứng dụng gửi trên 100 lệnh hàng ngày, manager interface sẽ làm việc tốt và không gây ra bất cứ crashes/deadlocks nào.
* đối với các ứng dụng gửi trên một nghìn lệnh manager đến Asterisk server từ các máy client khác nhau hàng ngày, bạn sẽ gặp fải ít nhất một lần crash/deadlock xảy ra một ngày.
* Bạn có thể kết nối đến asterisk manager interface thông qua bất cứ ngôn ngữ lập trình nào có thực thi vào ra qua socket (C, Python, Perl, PHP, etc…)

* you can program an AGI to use the manager even(it you really wanted to)

Tôi đã giải quyết vấn đề CRASH như thế nào:

Tôi có một vấn đề, tôi sử dụng manager interface qua 30 máy desktop để thực hiện một số lớn các lệnh redirect, originate, recording, hangup và command actions lên đến khoảng 5000 commands một ngày. Điều này dẫn tới 4 crashes/deadlocks / ngày trên Asterisk servers của tôi.

That’s when I started to look hard at a centralized manager queue. After some initial testing I determined that the best way for me to process all of these actions was to have a database driven system by which two constantly running scripts would separately send and parse manager actions and events.

(có một hệ thống DB và 2 script sẽ chạy riêng biệt để gửi và phân tích các action và sự kiện)

Ví dụ với lệnh Originate:

1. client chèn một Originate record vào queue table (với giá trị Callerid duy nhất)
2. ứng dụng action_sender sẽ lấy ra record mới, gửi action và đánh dấu record là SENT
3. ứng dụng manager_listen sẽ phân tích các dòng của manager output và gửi các lệnh blind UPDATE đến database dựa trên trường action CallerID and/or the uniqueid field for a key – in the manager interface the callerid field can be unique to the call as sent into the manager
4. client có thể lấy các giá trị uniqueid và channel từ database, giờ đây bản ghi đã được xử lý.

Under this process there is no risk of losing a manager connection on the
client machine, all manager connections exist on the localhost Asterisk
machine. Also, there is very little lag in processing actions through this
model even on a busy machine.

My suggestions for improving the manager interface:

* make it more fault tolerant, I can live with the querky API and data formatting, but buffer overflows and not killing inactive connections causing crashes/deadlocks is VERY bad.

* make a simple manager action file parser(sample.action), something like the sample.call interface except for manager actions, for output you can have the manager generate a sampleaction.out file that would have the output for that specific command on it. Many people that currently use the sample.call format would love to have a simple way to add manager functions to their apps that already generate sample.call files

* make a transaction-based send-receive protocol, something like the HTTP protocol. This would be a lot more involved than the sample.action idea, but it is probably a step in the right direction for the future of Asterisk (this one isn’t my idea, “jayson” is working on thishttp://bugs.digium.com/bug_view_page.php?bug_id=0000123)

Well, that’s the end of my rambling for now, hope this helps.

MATT–

A Note About Busy
(Joel Rowbottom, joel <at> enovi <dot> com)

Annoyingly, the Manager API doesn’t seem to return ‘Busy’ at all – instead just giving back a Hangup with no result codes.

December 28, 2006

[voip] Asterisk Concepts – Extension 01

Filed under: VOIP News — encyclopedia @ 8:05 am

Khi ta khai báo các sip phone trong sip.conf thì mỗi sip phone có một trường quy định context của nó. Trường này rất quan trọng vì khi sip phone gọi đi, asterisk  sẽ tìm đến context có đúng tên đó trong file extensions.conf để thực hiện kịch bản gọi tương ứng.

December 24, 2006

[asterisk] BOOKS & Links

Filed under: VOIP News — encyclopedia @ 6:42 am

http://www.simitel.com/resources/booklet1/ (* – FOTF )

Programming with C#: http://www.voip-info.org/wiki/view/Asterisk+manager+Example%3A+C+Sharp

http://www.asteriskdocs.org/modules/tinycontent/content/docbook/

http://www.fredshack.com/docs/asterisk.html

Link về Asterisk của digium: http://forums.digium.com/viewtopic.php?t=3148

http://www.answers.com/topic/asterisk-pbx

–AMI soft——————————-
Asterisk Manager Suite (AMS)

http://www.intuitivecreations.com/contributions/AMS/

–Blog————————————

http://lorancestinson.blogspot.com/search/label/Asterisk

http://nerdvittles.com/index.php?p=158

–Asterisk Architecture——————-

Asterisk Module Generator

http://www.lobstertech.com/code/asterisk_module_generator/

Writing Native Extensions for Asterisk 1.2

http://www.lobstertech.com/doc/ast-12-func/

[asterisk] Thông tin thêm về asterisk 00

Filed under: VOIP News — encyclopedia @ 6:06 am

Cài đặt Asterisk
Vào trang web www.asterisk.org để download gói asterisk.
Giải nén gói tin bằng lệnh tar –xzvf tênfile.tar
Vào thư mục vừa giải nén, và nhập các lệnh sau để cài Asterisk

# cd /user/src/asterisk-version
# make clean
# make
# make install
# make samples

Mặc nhiên, Asterisk được cài ở thư mục /usr/sbin/asterisk. Nếu bạn nhập lệnh /usr/sbin/asterisk thì nó sẽ chạy ở deamon (services). Tuy nhiên bạn có thể vào chế độ dòng lệnh để theo dõi chi tiết.

Trong trường hợp bạn muốn khám phá tất cả các tham số của Asterisk, bạn dùng lệnh asterisk –h.

Dưới đây là vài tham số:
-c : Vào chế độ cosole
-v : Tăng mức độ thông báo chi tiết để kiểm tra hoạt động của Asterisk
-r : Remote. Dùng để kết nối lại Asterisk nếu Asterisk đang chạy ở dạng deamon.

——————————–

Một vài lệnh cơ bản ở chế độ Console:
Sip show peers: xem trạng thái kết nối của các điện thoại SIP.
Stop now: dừng và thoát Asterisk
Reload: nạp lại dịch vụ Asterisk

———————————

Vài thư mục mà Asterisk sử dụng
/etc/asterisk : chứa các file cấu hình
/usr/lib/asterisk/modules/ được dùng để chứa các loadable modules như là codec, format, channels được dùng bởi Asterisk. Mặc định, Asterisk sẽ load tất cả các module này. Bạn có thể tắt bớt trong tệp modules.conf

—————————
/var/lib/asterisk chứa tệp astdb và một số thư mục con. Tệp astdb chứa các thông tin database, tương tự như Microsoft Windows Registry. Asterisk database dựa trên v1 của Barkeley database. Nó dùng version 1 vì lý do bản quyền.
Các thư mục con như sau:

* agi-bin/ chứa các custom scripts và có thể được dùng với nhiều ứng dụng AGI.
* Firmware/ chứa nhiều phiên bản firmware của asterisk devices
* Images/ chứa nhiều kênh hỗ trợ hình ảnh được chứa trong thư mục images/.
* Keys/ chứa các public hoặc private key
* Mohmp3/ chứa music on hold
* Sounds

/var/spool/asterisk chứa nhiều thành phần liên quan đến chi tiết cuộc gọi.
/var/run chứa process ID của tất cả các active process trên máy, bao gồm cả asterisk.
/var/log/asterisk
/var/log/asterisk/cdr-csv được dùng để chứa CDR theo định dạng CSV. Theo mặc định thì nó chứa trong file Master.csv, nhưng các account riêng lẻ có thể cất trong từng file riêng biệt theo accountcodem

———————-

Vài tệp cơ bản cần nhớ để cấu hình Asterisk
Extensions.conf là file chứa dial plan
Sip.conf dùng để cấu hình giao thức SIP.
Iax.conf dùng cấu hình các kênh truyền của giao thức IAX.

[asterisk] Đột fá lĩnh vực viễn thông

Filed under: VOIP News — encyclopedia @ 5:55 am

Asterisk đột phá lãnh địa viễn thông

Cập nhật lúc 15h15″ , ngày 19/01/2006
a0601_cn_95.jpg
M. Spencer phát biểu tại hội nghị VON (sự kiện hàng năm lớn nhất về truyền thông IP): “Asterix sẽ làm thay đổi bộ mặt ngành công nghiệp viễn thông”.

Năm năm sau sự đổ vỡ “dot-com”, giới đầu tư công nghệ lại xôn xao với sản phẩm của chàng trai chưa đầy 30 tuổi, tác giả phần mềm nguồn mở Asterix được cho là sẽ làm thay đổi ngành công nghiệp viễn thông.

Thị trường viễn thông nói chung và hệ thống tổng đài PBX (Private Branch Exchange) nói riêng, từ lâu nay là lãnh địa đầy lợi nhuận dành riêng của các “đại gia” như Alcatel, Lucent, Nortel và Avaya… Theo Research and Markets (www.researchandmarkets.com), thị trường thiết bị PBX trị giá khoảng 13 tỉ USD/năm và được kỳ vọng sẽ lên đến 30 tỉ USD vào năm 2009. Tuy nhiên, lãnh địa này đang bị đe dọa bởi sản phẩm của chàng trai chưa đầy 30 tuổi (sinh năm 1977) – Mark Spencer, tác giả phần mềm nguồn mở Asterisk.

Asterisk là phần mềm thực hiện chức năng tổng đài điện thoại nội bộ (PBX), cho phép các máy điện thoại nhánh (extension) thực hiện cuộc gọi với nhau và kết nối với các hệ thống điện thoại khác bao gồm cả mạng điện thoại analog thông thường (PSTN) và VoIP. Asterisk có đầy đủ tính năng của tổng đài PBX thương mại: phân luồng cuộc gọi, thư thoại, hội đàm, tương tác (menu thoại)… Đặc biệt, Asterisk còn hỗ trợ nhiều giao thức VoIP như SIP và H.323, hoạt động như trạm kết nối giữa các điện thoại IP và mạng PSTN.

Asterisk miễn phí theo giấy phép GPL. Tên Asterisk có nguồn gốc từ ký hiệu * được dùng trong Unix và Linux, thể hiện cho tùy chọn bất kỳ.

Lịch sử

Cũng như nhiều dự án nguồn mở, Asterisk thoạt đầu được xây dựng nhằm đáp ứng nhu cầu cá nhân. Khi còn là sinh viên khoa kỹ thuật máy tính tại đại học Auburn ở Alabama (Mỹ), M. Spencer đã thành lập công ty cung cấp dịch vụ hỗ trợ người dùng Linux qua điện thoại. Để tiết kiệm chi phí, thay vì mua tổng đài PBX có sẵn (giá rất đắt), Mark đã quyết định tự xây dựng phần mềm thực hiện chức năng tổng đài chạy trên PC dùng hệ điều hành Linux và kết quả là Asterisk ra đời.

Một trong những vấn đề quan trọng mà M. Spencer phải đối mặt đó là tìm phần cứng để kết nối PC với hệ thống PSTN. Mark đã hợp tác với Jim Dixon trong dự án Zaptel (hay Zapatal Telephony Project, http://www.zapatatelephony.org) để thiết kế card giao tiếp rẻ tiền dùng cho PC trên nền Intel. Ý tưởng của dự án nhằm cho phép người ta có thể mua PC ở bất kỳ đâu, gắn thêm card giao tiếp, cài đặt Asterisk và thế là có tổng đài PBX đầy đủ tính năng.

Card giao tiếp Zaptel thực hiện tốt việc kết nối máy chủ Asterisk trực tiếp với PSTN, nhưng lại phát sinh nhu cầu liên lạc qua giao thức Internet (IP hay Frame Relay). Không thích H.323 cồng kềnh, Mark quyết định thiết kế một giao thức khác gọn nhẹ hơn và kết quả là giao thức IAX (Inter Asterisk eXchange) ra đời. Tuy cái tên hàm ý phương thức trao đổi tín hiệu giữa các máy chủ Asterisk, nhưng thực tế IAX có thể kết nối các thiết bị bất kỳ có hỗ trợ giao thức này. Để có khả năng liên lạc với các hệ thống VoIP khác, Asterisk cũng hỗ trợ các giao thức VoIP phổ biến như SIP (chuẩn IETF), H.323 (chuẩn ITU), MGCP, VoFR…

a0601_cn_92.gif
Nguyên tắc hoạt động hệ thống PBX-Asterisk

Từ Zaptel đến Digium và IAXTEL

Về nhiều phương diện, M. Spencer và phần mềm Asterix có khả năng tác động đến thị trường PBX tương tự như những gì Linus Torvalds đã làm đối với thị trường hệ điều hành khi đưa ra bản Linux đầu tiên vào năm 1991. Tuy nhiên, M. Spencer cho rằng có khác biệt lớn giữa anh và Torvald đó là anh muốn kiếm tiền từ công nghệ của mình.

Sau thành công của dự án Zaptel, M. Spencer nhìn thấy cơ hội nên đã thành lập công ty Digium chuyên phát triển và bán phần cứng Zaptel đồng thời hỗ trợ phát triển phần mềm Asterisk. Phần mềm Asterisk vẫn đảm nhận các chức năng xử lý và PBX chính. Việc tiếp tục miễn phí Asterisk giúp Digium có được phản hồi và sự đóng góp từ các nhà phát triển trên khắp thế giới.

Mô hình kinh doanh của Digium là sản xuất card giao tiếp làm việc dễ dàng với Asterisk, cung cấp các ứng dụng bổ sung cho Asterisk, hỗ trợ kỹ thuật và tư vấn.

Tháng 7/2003, Digium công bố IAXTEL (www.iaxtel.com), “chủ yếu phục vụ cho các nhà phát triển và những người ưa thích kiểm tra hệ thống của mình và nghiên cứu VoIP”. Người dùng Asterisk và các nhà phát triển có thể kết nối điện thoại và PBX của mình đến IAXTEL miễn phí dùng giao thức IAX.

a0601_cn_94a.jpg
Card giao tiếp của Digium kết nối máy tính với PSTN

Ứng dụng uyển chuyển

Asterisk cực kỳ linh hoạt, có thể kết nối với mạng điện thoại bên ngoài qua đường tương tự (analog) hay số (digital), và có thể phân luồng cuộc gọi nội bộ qua cáp điện thoại truyền thống hay mạng IP (mạng máy tính).

Phần mềm Asterisk được thiết kế dạng môđun. Các thành phần chức năng được thiết kế thành từng môđun riêng biệt và tách rời với phần chuyển mạch lõi, điều này tạo khả năng dễ điều chỉnh và mở rộng cao. Một trong những “điểm son” của Asterisk là phần quản lý extension. Từng bước của cuộc gọi được định nghĩa như một ứng dụng. Quay số là một ứng dụng; trả lời, phát lại, thư thoại… là những ví dụ ứng dụng khác. Ta có thể tạo kịch bản thực hiện gọi ứng dụng bất kỳ trên kênh bất kỳ. Ví dụ, có thể thiết lập một số extension được đổ chuông cùng lúc ở 2 kênh (có thể nối đến 2 máy điện thoại: 1 analog và 1 digital) trước khi chuyển cuộc gọi đến điện thoại di động, và sau đó chuyển qua hệ thống thư thoại.

Asterisk cung cấp 4 bộ API dùng cho việc giao tiếp với các môđun:

• Channel API: cho phép phần lõi PBX giao tiếp với các nguồn tín hiệu khác nhau, hỗ trợ các giao thức VoIP gồm SIP, H.323 và MGCP.
• Codec Translator API: cung cấp khả năng làm việc với các định dạng âm thanh mã hóa như MP3, GSM, G.7123, ADPCM…
• File Format API: Cho phép đọc và phát âm thanh từ các định dạng file WAV, MP3…. đem đến sự linh hoạt cho các ứng dụng trên nền Asterisk trong việc xử lý âm chuông, DTMF (âm thanh phát ra khi nhấn phím)…
• Application API: Có thể dùng cho ứng dụng thứ ba như thư thoại, hội đàm… cho phép viết các ứng dụng mới có thể tương tác trực tiếp với phần lõi PBX.

Ngoài ra, Asterisk còn có thư viện Asterisk Gateway Interface (AGI, tương tự như CGI) – cơ chế kích hoạt ứng dụng bên ngoài, cho phép viết kịch bản phức tạp với một số ngôn ngữ như PHP hay Perl. Nói chung, khả năng viết các ứng dụng tùy biến rất lớn.

Asterisk thoạt đầu được phát triển trên GNU/Linux nền x86 (Intel), nhưng giờ đây nó cũng có thể biên dịch và chạy trên OpenBSD, FreeBSD và Mac OS X và Microsoft Windows.

Sẽ lớn hơn Linux

Theo nhận định của Jon maddog Hall – chủ tịch tổ chức Linux International, VoIP sử dụng giải pháp nguồn mở như Asterisk sẽ có thị trường lớn hơn Linux. Asterisk cho phép ngay cả công ty hay tổ chức nhỏ cũng có thể thiết lập hệ thống điện thoại đa năng, hỗ trợ đồng thời điện thoại thông thường (analog) và điện thoại IP (VoIP). Theo M. Spencer, Asterisk là giải pháp “viễn thông cho đại chúng” – ngoài chi phí rẻ và dễ dàng thiết lập, khả năng VoIP của Asterisk cho phép “kết nối” những vùng xa xôi, những nơi chưa có mạng cáp điện thoại truyền thống.

Hầu như công ty hay tổ chức nào cũng đều cần hệ thống điện thoại nội bộ (cùng với tổng đài PBX) và đa phần đều có trang bị hệ thống mạng máy tính (ngày càng trở nên không thể thiếu), Asterisk có thể giúp “hợp nhất” hai hệ thống này và giúp hệ thống mạng máy tính-điện thoại nội bộ hòa nhập thông suốt với thế giới bên ngoài, cả mạng Internet lẫn viễn thông. Thị trường cho Asterisk thật lớn.

GIẢI PHÁP VOIP SIÊU RẺ

Hiện nay, hầu như công ty nào cũng có mạng máy tính. Cơ sở hạ tầng IT sẵn có này có thể khai thác để thiết lập hệ thống điện thoại nội bộ và có thể tiết kiệm chi phí đáng kể (gồm cả cước phí điện thoại). Chí phí thiết lập? Tất cả không đến 10USD cho phần cứng cùng với phần mềm miễn phí.

Phần cứng

Bạn có thể sử dụng máy tính sẵn có, cấu hình không yêu cầu cao (tối thiểu: PIII, 256MB RAM, 12GB HDD, CDROM, card mạng), và đăng ký dịch vụ cung cấp tín hiệu VoIP (như 171-VNPT, 177-SPT và 178-Viettel). Nếu muốn sử dụng đường điện thoại analog thông thường, bạn cần có card modem. Card PCI Digium Wildcard X100P được sử dụng phổ biến nhất, hiện bạn có thể mua card mới trên eBay với giá dưới 10USD. (Hãng Digium hiện đã ngưng sản xuất card X100P và thay bằng TDM01B).

Wildcard X100P chỉ hỗ trợ 1 đường (line) điện thoại analog. Digium còn có card hỗ trợ 4 line, 24 line analog và dòng card dùng cho kênh số T1 (24 line) / E1(32 line). Ngoài Digium, còn có một số hãng khác cung cấp các card giao tiếp tương thích (giá có thể rẻ hơn).
a0601_cn_94b.jpg

Phần mềm

Chúng ta sử dụng gói phần mềm nguồn mở miễn phí Asterisk@Home (http://asteriskathome.sourceforge.net), có thể tải về file .iso để ghi CD.

Khởi động máy tính với đĩa CD Asterisk để thực hiện cài đặt. Lưu ý: việc cài đặt này sẽ xoá toàn bộ dữ liệu trên đĩa cứng. Asterisk sẽ được biên dịch từ mã nguồn (source) theo phần cứng PC của bạn.

Đăng nhập vào Asterisk với tài khoản user:root, password:password (nếu máy tính có kết nối Internet, hãy thay đổi ngay password của root); bạn sẽ được cung cấp địa chỉ url để truy cập giao diện web. Sử dụng lệnh help-aah để xem danh sách các lệnh, lệnh asterisk -r để truy cập các thiết lập cấu hình, chạy script genzapptelconf để cấu hình Wildcard X100P. Để thiết lập cho hệ thống làm việc, bạn có thể chỉ cần sử dụng Asterisk Management Portal (AMP) ở giao diện web, đăng nhập với tài khoản maint/password.

Asterisk cho phép thiết lập đủ các tính năng PBX, như: chuyển cuộc gọi, nhận diện cuộc gọi, hội đàm, cấm quấy rối, thư thoại, đáp trả tương tác (IVR)… và đặc biệt tính năng VoIP. Danh sách tính năng đầy đủ có thể tham khảo ở asterisk.org.
a0601_cn_94c.gif

Lựa chọn extension

Hệ thống PBX IP này cung cấp 3 lựa chọn điện thoại nhánh cho người dùng: ATA (Analog Telecommunications Adator) dùng với điện thoại thông thường, điện thoại SIP và softphone (phần mềm chạy trên PC). Nếu không muốn tốn thêm tiền, bạn có thể sử dụng giải pháp softphone miễn phí X-Lite (www.xten.com).
a0601_cn_94d.jpg

December 21, 2006

[voip] Recommended Website!!!

Filed under: VOIP News — encyclopedia @ 8:41 am

Mot so trang web ve voip:

http://snapvoip.blogspot.com

December 19, 2006

[asterisk] Installing asterisk 1.4.0

Filed under: VOIP News — encyclopedia @ 7:44 am

http://astrecipes.net/?n=216

AstRecipes » Compiling Asterisk 1.4 beta

If you want to check out what the buzz about the new Asterisk 1.4 is, there is one thing you got to do – download it and install it on your box. The compilation procedure is a bit different from the one of Asterisk 1.2, so we thought a brief tutorial would be helpful. As a point of reference, we imagine you’re going to build your new Asterisk on a machine preinstalled with TrixBox; this means your machine is very easy to reinstall from scratch if anything goes wrong. This also means that you can start playing with Asterisk 1.4 in a virtual machine, so you have no risk.

The first thing you have to do is to create a working directory for Asterisk (say /src/asterisk14beta)and download the latest version of Asterisk 1.4 beta in it; we have used the following:
star Asterisk Version 1.4.0-beta3
star Zaptel Version 1.4.0-beta2
star Libpri Version 1.4.0-beta1

It will also be necessary to erase your existing Asterisk system – see Removing Asterisk. Make sure neither Asterisk nor its required libs are running before attempting the installations.

You’ll also need a bit more software:
star The C++ developement environment
star The Iksemel library, in order to test the Google Talk integration (we sure want that!)
star The Gnu TLS package, as needed by Iksemel

Prerequisites
Getting all this software is fairly easy to get installed, thanks to the very powerful yum installed that ships with CentOS:

yum install gcc-g++

yum install gnutls-devel

The first command may download and update quite a lot of stuff; don’t worry and let it run.

You will then download the Iksemel v1.2 libary (first link on the left bar) and compile it like this:

tar zxvf iksemel-1.2.tar.gz

cd iksemel-1.2

./configure

make

make install

Installing Asterisk
The process of installing Asterisk is quite easy, as always. The most important changes have been the adoption of the standard GNU configure utility and a very nice menu configuration utility that will allow a simpler control on what you actually need to build.

tar zxvf zaptel-1.4.0-beta2.tar.gz

cd zaptel-1.4.0-beta2

./configure

make menuselect

At this point use the menuselect utility to select which zaptel hardware – if any – you have on board. Please remeber that if you want to exit keeping the changes you made, you must press x, while q will quit without saving.

The rest of the build process is as always was, so:

make

make install

cd ..

The Libpri library at the moment does not have the fancy new build method, so we revert to a traditional:

tar zxvf libpri-1.4.0-beta1.tar.gz

cd libpri-1.4.0-beta1

make

make install

cd ..

Now for Asterisk itself; the build process is simple as always. Make sure you have cleaned up your machine before proceeding, to avoid having modules compiled for 1.2 together with stuff for 1.4.

tar zxvf asterisk-1.4.0-beta3.tar.gz

cd asterisk-1.4.0-beta3

./configure

make menuselect

Have a tour with the menu select utility. This is a great step forward! it will state clearly which modules you can build and which you cannot, and why. It’s also very easy to turn off stuff you do not want, like channel drivers for protocols you do not need. See how there is a lot of new stuff in 1.4 – we’ll have to spend some time studying it in order to catch up with new stuff! :)

make

make install

make samples

cd ..

That’s it. Your Asterisk is now ready to rock! Start it up with

asterisk -vvvvvvvvvvvvvvc

And check the current version with the following command:

show version

Here we are. Nice experimenting!

We can try a few new things, like:
star Installing the Asterisk GUI

December 16, 2006

[voip] Asterisk Concepts – Dial plan 00

Filed under: VOIP News — encyclopedia @ 3:58 pm

5.1.2. extensions.conf – Dialplan applications

1. Introduction

In this tutorial we will introduce to you the commands(applications) you can use in extensions.conf. With their help you can make your dial plan, control and manage your calls.

NOTE: These applications are valid for the Asterisk version 1.0.9

NOTE:Information about the functions could be obtained by typing the command show functions

Information about a particular function could be obtained by typing show function <function name> on the Asterisk CLI

These applications are tested with our IAX softphone Idefisk. You could download it from here. For more information about this softphone please read our tutorial.

If you would like to test this application with the SIP channel you could read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX

 

2. List of all dial plan applications

1) General Commands

01. Authenticate – authenticate an user with a dialed pass code. You can use it if you what to restrict the access to the system. This application will require a password to be entered in order to continue with the execution.
02. SendDTMF – this application sends DTMF digits on a channel.
03. SendImage – this application allows you to send an image file to the caller.
04. SendText – this application allows you to send a text to the caller. You can use it to send a message before the connection and for advertising
05. SendURL- this application requests from the client to go to a specific URL.
06. System – this application could be useful if you want to execute a system command.
07. TrySystem – this application is very similar to System.
08. Wait – as you can conclude from the name of this application, it could be used for setting a definite period of time for waiting.
09. WaitMusicOnHold – this application plays a music on hold.
10. WaitExten – a variety of the command Wait.
11. WaitForRing(UNDER CONSTRUCTION) – this application waits the Ring application to be executed.
12. Transfer – this application is used when you want to transfer the caller to a remote connection.

2) Call Management (hangup, answer, dial, etc)

01. Answer – the purpose of this application is to answer a channel if it is ringing.
02. Busy – indicates busy mode.
03. ChanIsAvail – this application makes a check whether the channel is free.
04. Congestion – indicates congestion mode
05. Ringing – indicates ringing tone.
06. DISA – this application allows somebody from outside the PBX to make calls as if he is inside.
07. Hangup- just hanging up the line.
08. Dial(UNDER CONSTRUCTION) – this application makes a call and connect to a channel.

3) Control Flow and Timeouts

01. AbsoluteTimeout – with this application you can limit the duration of the call
02. DigitTimeout – this application sets the maximum time between two digits
03. Goto – with this application you can go to a particular priority, extension or context
04. GotoIf – a variety of GoTo.
05. GotoIfTime – similar to GoTo and GoToIf but you can add and a time.
06. Random – this application could be used if you wand to choose a random context, extension or priority
07. ResponseTimeout – this application sets the maximum time to wait for a response.

4) Sounds: Playing and Recording

01. Playback – this application plays a sound file
02. ControlPlayback – this application can play sound file. It also can control it.
03. MP3Player – with this application you can play a .mp3 files
04. Background – with this application you can play a sound file.
05. BackgroundDetect – whit this application you can play a sound file in the background and to stop it by voice
06. Playtones – whit this application you can play tones such as busy, congestion and etc.
07. StopPlaytones – whit this application you can stop the playing of a tone
08. SayUnixTime – this application says the date and the time
09. SayAlpha – this application says a specified string character by character.
10. SayDigits – this application says a specified number digit by digit.
11. SayNumber – this application says a specified number.
12. SayPhonetic – this application will say a specified string according to the NATO phonetic alphabet
13. Record – with this application you can record a message
14. Dictate – with this application you are allowed to record a voice and to store it in a file.
15. Monitor – with this application you can record a conversation
16. MixMonitor – with this application you are allowed to record conversations. It is an updated version of the Monitor application.
17. ChangeMonitor – with this application you can change the filename used by the Monitor application
18. StopMonitor – this application stops the action of the Monitor one
19. MusicOnHold – this application plays music on hold
20. SetMusicOnHold – this application sets a class for music on hold
21. Echo – this application returns the outgoing audio from a channel back to the channel
22. Milliwatt – this application generates an endless signal
23. SetLanguage – this application changes the preferable language
24. Festival(UNDER CONSTRUCTION) -

5) Caller presentation (ID, Name etc)

01. LookupBlacklist – this application checks the Asterisk`s database for blacklisted caller IDs
02. LookupCIDName – this application checks in the Asterisk`s database for the caller number
03. Zapateller – this application plays tone used for blocking a telemarketers
04. SetCallerID – this application sets the ID of the caller.
05. SetCIDName – this application could change the Caller ID Name
06. SetCIDNum – this application could change the Caller ID Number
07. SetCallerPres(UNDER CONSTRUCTION) -
08. CallingPres(UNDER CONSTRUCTION) -
09. PrivacyManager(UNDER CONSTRUCTION) -
10. SoftHangup(UNDER CONSTRUCTION) -

6) Database handling

01. DBdel – this application could remove a key from the Asterisk`s database
02. DBdeltree – this application removes a key tree from the Asterisk`s database
03. DBget – this application retrieves a value from the Asterisk`s database
04. DBput – this application stores a value in the Asterisk`s database

7) Voicemail and conferencing

01. Directory – this application says a list of extensions.
02. VoiceMail – this application could leave a voice message in a voicemail box
03. VoiceMailMain – this application gives you an access to the Asterisk’s voicemail system
04. HasNewVoicemail – this application checks for new message in a specified mailbox
05. HasVoicemail – this application is improved version of the previous one.
06. MailboxExists – this application checks whether a specified mailbox exist.
07. MeetMe – this application allows you to create an conference calls.
08. MeetMeCount – this application gives you information about the number of participants in a conference.
09. MeetMeAdmin(UNDER CONSTRUCTION)

8) String & variable manipulation

01. Cut – this application could cut strings
02. Prefix – this application adds digits in front of the extension number
03. Suffix – this application adds digits in the end of the extension number
04. StripLSD – this application removes digits from the end of the extension number
05. StripMSD – this application removes digits from the beginning of the extension number
06. Set – this application sets a value to a variable
07. SetVar – this application is deprecated. Use the Set application.
08. SetGlobalVar – this application could set a value to a global variable.
09. SubString -

9) Queue and ACD management

01. Queue – thanks to this application you can attach a call in a queue.
02. AddQueueMember – with this application you can add an agent(member) in your queue.
03. AgentCallbackLogin – the application allows you to log in an agent, into a queue, with callback.
04. AgentLogin – the application allows you to log in an agent into a queue.
05. RemoveQueueMember – this application allows you to remove, dynamically, an agents or members, from a queue.
06. PauseQueueMember – this application allows you to stop, temporary, the answering of calls in the queue, from a specific member.
07. UnpauseQueueMember – the usage of this application will cancel the effect of the PauseQueueMember application.
08. AgentMonitorOutgoing – this application allows you to figure out the Caller ID of the agent, who is making an outgoing call.
09. ParkedCall – this application answers parked calls
10. Park – this application allows you to park yourself.
11. ParkAndAnnounce

10) Application integration

01. NoOp – this application could be used for debugging.
02. Macro – this application is used for executing a macro.
03. MacroIf – this application executes macro if some condition is true or false.
04. MacroExit – this application allow you to exit from a macro.
05. Read – this application reads a variable.
06. ReadFile – this application reads a file.
07. TXTCIDName
08. UserEvent
09. EnumLookup
10. AGI
11. EAGI
12. DeadAGI

11) Fax

01. RxFax – this application allows you to receive faxes from a fax machine to the Asterisk

////—- All tutorials below this point are under construction —-////

12) Billing

01. ForkCDR – this application forks the Call Data Record(CDR)
02. NoCDR – this application prevent Asterisk PBX to safe the CDR for certain call
03. ResetCDR – this application resets the CDR
04. SetAccount – this application sets an account code for billing purposes.
05. SetAMAflags – this application sets AMA flags
06. SetCDRUserField – this application set the CDR user field with a value
07. AppendCDRUserField – very similar to the previous one this application appends a value to the CDR user field.

13) ZAP commands

01. Flash
02. ZapBarge
03. ZapRAS
04. ZapScan

14) SIP commands

01. SIPdtmfMode
02. SIPGetHeader
03. SIPAddHeader
04. suplimental resource SIPCallPickup
05. sipredirect

15) Alarm Monitoring/Central Station

01. AlarmReceiver

16) Amateur Radio/Repeater Linking

01. Rpt

17) External applications (not in the CVS)

01. Asterisk app_dbodbc
02. DynExtenDB
03. Iconv
04. LDAPget
05. app Prepaid
06. PPPD

18) Bristuff applications

01. PickUp
02. PickUpChan
03. PickDown
04. Steal
05. Devstate
06. Segfault
07. ZapEC
08. Autoanswer
09. AutoanswerLogin

19) Applications for Sirrix channels

01. SrxEchoCan
02. SrxDeflect
03. SrxMWI

20) ADSI

01. ADSIProg
02. GetCPEID

 

3. Additional information

If you are unfamiliar with the extensions.conf file, please read our tutorial about it, here

You could also visit out tutorial about the Asterisk dialplan functions

————————————————————-
————————————————————-

5.1.1. extensions.conf – Dialplan functions – NEW

1. Introduction

In this tutorial we will introduce to you the functions which you could use in extensions.conf.

NOTE: These functions are valid for the Asterisk version 1.2. and up.

They will replace some of the application from the previous Asterisk versions. With their help you will make your dialplan, control and manage your calls.

NOTE:Information about the functions could be obtained by typing the command show functions

Information about a particular function could be obtained by typing show function <function name> on the Asterisk CLI

These applications are tested with our IAX softphone Idefisk. You could download it from here. For more information about this softphone, please read our tutorial.

If you would like to test this application with the SIP channel you could read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX

 

2. List of all dialplan functions

01. CUT – this function allows you to split the content of a variable by using a specified delimiter.
02. CALLERID(all) – this function allows you to set the ID of the caller.
03. CALLERID(name) – this function allows you to set the Name of the caller
04. CALLERID(num) – this function allows you to set the Number of the caller.
05. CALLERID(rdnis) – this function will allow you change the RDNIS number
06. LANGUAGE – this function allows you to change the used language.
07. TIMEOUT(absolute) – this function allows you to limit the duration of the conversation.
08. TIMEOUT(digit) – this function allows you to limit the time interval between digits when the user is typing an extension.
09. TIMEOUT(response) – this function allows you to limit the maximum time for waiting a response.
10. DB(get) – this function allows you to retrieve or store a value in the Asterisk’s database.
11. DB(put) – this function allows you to retrieve or store a value in the Asterisk’s database.
12. CDR(accountcode) – this function allows you to change the Account Code of the caller
13. MATH – this function allows you to perform simple mathematical operations.
14. CHECK_MD5 – this function allows you to compare two MD5 checksums
15. MD5 – this function allows you to calculate MD5 checksum on a string.

3. Additional information

If you are unfamiliar with the extensions.conf file, please read our tutorial about it, here.

You could also visit out tutorial for the Asterisk dialplan applications

 

[voip] Asterisk Concepts – SIP configuration 00

Filed under: VOIP News — encyclopedia @ 8:26 am

Đây là file cấu hình SIP sip.conf cơ bản:

[general]
context=default
srvlookup=yes
[john]
type=friend
secret=welcome
qualify=yes ; Qualify peer is no more than 2000 ms away
nat=no ; This phone is not natted
host=dynamic ; This device registers with us
canreinvite=no ; Asterisk by default tries to redirect
context=internal ; the internal context controls what we can do

File sip.conf bắt đầu với phần [general], chứa các thiết lập kênh và các tuỳ chọn mặc định cho tất cả các users và peers được định nghĩa trong sip.conf. Bạn có thể thay đổi các thiết lập mặc định với từng user/peer bằng cách cấu hình chúng trong user/peerdefinition.

Các bản ghi Domain Name System Service (DNS SRV records) are a way of setting up a logical, resolvable address where you can be reached. Điều này cho phép các cuộc gọi được chuyển tiếp (forward) tới các vị trí khác nhau mà không fải thay đổi địa chỉ logic. Bằng cách sử dụng các SRV record, bạn có thể đạt được nhiều ưu điểm khi sử dụng DNS, ngược lại nếu vô hiệu hoá chúng thì sẽ phá vỡ SIP RFC và mất khả năng tạo các cuộc gọi SIP dựa trên các domain names. (Chú ý rằng nếu nhiều bản ghi được returned, Asterisk sẽ chỉ sử dụng bản ghi đầu.)

Việc tra cứu DNS SRV record được vô hiệu hoá mặc định trong Asterisk, nhưng bạn nên bật tính năng này lên. Để enable, hãy set srvlookup=yes trong section [general] của sip.conf.
Mỗi connection được định nghĩa như một user, peer, hay friend. Một kiểu user được sử dụng để xác nhận các cuộc gọi đến, kiểu peer được sử dụng cho các cuộc gọi ra ngoài, và kiểu được sử dụng cho cả hai. Extension name được định nghĩa trong một cặp ngoặc vuông ([]). Trong trường hợp này, chúng ta đã định nghĩa extension john như là một friend.

Secret là một password sử dụng để xác nhận. Secret của ta được định nghĩa là welcome. Chúng ta có thể monitor độ trễ giữa Asterisk server và phone với qualify=yes, do đó việc xác định remote device là có thể reachable hay không. qualify=yes có thể được sử dụng để monitor bất cứ device cuối nào, bao gồm các Asterisk servers. Về mặc định, Asterisk sẽ xem xét một extension là reachable nếu độ trễ nhỏ hơn 2,000 ms (2 seconds). Bạn có thể cấu hình thời gian Asterisk sẽ sử dụng khi xác định một peer là có thể reachable hay không bằng việc thay thế yes với số milliseconds.

Nếu một extension nằm tại một device có Network Address Translation (NAT), như một router hay firewall, set nat=yes để bắt buộc Asterisk bỏ qua contact information đối với extension và sử dụng địa chỉ từ đó các gói đang được nhận. Vệc Set host=dynamic sẽ cần extension fải đăng ký để cho Asterisk biết làm thế nào để có thể reach được phone. Để giới hạn một endpoint thành một địa chỉ IP đơn hay một fully qualified domain name (FQDN), hãy thay thế dynamic bằng địa chỉ IP hay domain name. Chú ý rằng điều này chỉ giới hạn ở nơi bạn gọi đến, vì người dùng được phép gọi từ bất cứ đâu (giả sử đã đăng ký thành công). Nếu bạn set host=static, thiết bị cuối sẽ không cần fải đăng ký.

Chúng ta cũng đồng thời set canreinvite=no. Trong SIP, các invites được sử dụng để thiết lập các cuộc gọi và để redirect (chuyển hướng) media. bất cứ invite được fát ra sau invite đầu tiên trong cùng một cuộc hội thoại (dialog) thì được coi là một reinvite.

Ví dụ, giả sử 2 parties đang trao đổi một lưu lượng media. Nếu một client thực hiện on-hold và Asterisk được cấu hình để play Music on Hold (MoH), Asterisk sẽ fát ra một reinvite tới client thứ hai, báo cho nó redirect dòng media đến PBX. Asterisk sau đó có khả năng truyền dòng (stream) music hay một announcement tới on-hold client.

Client chính sau đó fát ra một lệnh off-hold trong một reinvite tới PBX, sau đó asterisk lại fát ra một reinvite tới party thứ hai yêu cầu nó redirect dòng media của nó đến party chính, do đó kết thúc on-hold music và reconnecting các clients.

Thông thường, khi hai endpoints thiết lập một cuộc gọi chúng sẽ truyền trực tiếp media đến người kia. Asterisk thông thường sẽ fá vỡ luật này tồn tại trong đường truyền media, cho phép nó lắng nhe các digits bấm trên phone’s keypad. Điều này là cần thiết vì nếu Asterisk không thể xác định được độ dài cuộc gọi, việc tính toán tiền có thể nhầm lẫn. Việc cấu hình canreinvite=no bắt buộc Asterisk nằm trong media path, không cho phép các thông điệp RTP trao đổi trực tiếp giữa các endpoints.

Asterisk sẽ không fát ra một reinvite trong bất cứ trường hợp nào sau đây:
• Nếu một trong 2 client được cấu hình canreinvite=no
• Nếu các clients không có chung thiết lập codec Asterisk và Asterisk fải thực thi việc chuyển đổi codec
• Nếu có clients được cấu hình với nat=yes
• Nếu Asterisk cần lắng nghe các âm Dual Tone Multi-Frequency (DTMF) trong cuộc gọi (để transfers hay cho other features)
Cuối cùng, context=internal chỉ ra vị trí của các chỉ dẫn được sử dụng để điều khiển những gì phone được phép làm, và xử lý các cuộc gọi đến extension.

Context name được cấu hình trong sip.conf trùng với tên của context trong extensions.conf, là file chứa các chỉ dẫn. Nhiều thông tin hơn về các contexts và dialplans sẽ được trình bày trong các chương sau.

Nếu bạn đang cấu hình một số các clients với cùng configurations, bạn có thể đặt like commands trong [general] heading. Asterisk sẽ sử dụng các mặc định chỉ ra trong [general] section trừ khi chúng đc thay đổi rõ ràng trong một client’s configuration block.

Older Posts »

Blog at WordPress.com.