11.8. Layanan Komunikasi Real-Time
Real-Time Communication (RTC) services include voice, video/webcam, instant messaging (IM) and desktop sharing. This chapter gives a brief introduction to three of the services required to operate RTC, including a TURN server, SIP server and XMPP server. Comprehensive details of how to plan, install and manage these services are available in the Real-Time Communications Quick Start Guide which includes examples specific to Debian.
SIP dan XMPP dapat menyediakan fungsionalitas yang sama. SIP sedikit lebih dikenal untuk suara dan video sementara XMPP secara tradisional dianggap sebagai protokol IM. Pada kenyataannya, keduanya dapat digunakan untuk tujuan ini. Untuk memaksimalkan pilihan konektivitas, disarankan untuk menjalankan keduanya secara paralel.
11.8.1. Pengaturan DNS untuk layanan RTC
Layanan RTC memerlukan record DNS SRV dan NAPTR. Suatu contoh konfigurasi yang dapat ditempatkan dalam berkas zona untuk falcot.com
:
; server tempat semua akan dijalankan
server1 IN A 198.51.100.19
server1 IN AAAA 2001:DB8:1000:2000::19
; IPv4 only for TURN for now, some clients are buggy with IPv6
turn-server IN A 198.51.100.19
; IPv4 and IPv6 addresses for SIP
sip-proxy IN A 198.51.100.19
sip-proxy IN AAAA 2001:DB8:1000:2000::19
; IPv4 and IPv6 addresses for XMPP
xmpp-gw IN A 198.51.100.19
xmpp-gw IN AAAA 2001:DB8:1000:2000::19
; DNS SRV and NAPTR for STUN / TURN
_stun._udp IN SRV 0 1 3467 turn-server.falcot.com.
_turn._udp IN SRV 0 1 3467 turn-server.falcot.com.
@ IN NAPTR 10 0 "s" "RELAY:turn.udp" "" _turn._udp.falcot.com.
; DNS SRV and NAPTR records for SIP
_sips._tcp IN SRV 0 1 5061 sip-proxy.falcot.com.
@ IN NAPTR 10 0 "s" "SIPS+D2T" "" _sips._tcp.falcot.com.
; DNS SRV records for XMPP Server and Client modes:
_xmpp-client._tcp IN SRV 5 0 5222 xmpp-gw.falcot.com.
_xmpp-server._tcp IN SRV 5 0 5269 xmpp-gw.falcot.com.
TURN adalah layanan yang membantu klien di belakang firewall dan router NAT untuk menemukan cara yang paling efisien untuk berkomunikasi dengan klien lain dan me-relay stream media jika tidak ditemukan path media yang langsung. Sangat dianjurkan untuk memasang server TURN sebelum salah satu layanan RTC lain ditawarkan kepada pengguna akhir.
TURN dan protokol ICE yang terkait adalah standar terbuka. Untuk memperoleh manfaat dari protokol-protokol ini, memaksimalkan konektivitas dan meminimalkan frustrasi, itu penting untuk memastikan bahwa semua perangkat lunak klien mendukung ICE dan TURN.
Agar algoritma ICE bekerja secara efektif, server harus memiliki dua alamat IPv4 publik.
Install the coturn package and edit the /etc/turnserver.conf
configuration file. By default, a SQLite database is configured in /var/db/turndb
for user account settings, but PostgreSQL, MySQL or Redis can be set up instead if preferred. The most important thing to do is insert the IP addresses of the server.
The server can be started running /usr/bin/turnserver
. We want the server to be an an automatically started system service, so we edit the /etc/default/coturn
file like this:
#
# Uncomment it if you want to have the turnserver running as
# an automatic system service daemon
#
TURNSERVER_ENABLED=1
By default, the TURN server uses anonymous access. We have to add the users we want to use:
#
turnadmin -a -u roland -p secret_password -r falcot.com
#
turnadmin -A -u admin -p secret_password
We use the argument -a
to add a normal user and -A
to add an admin user.
11.8.3. Server Proksi SIP
Server proksi SIP mengelola koneksi SIP masuk dan keluar antara organisasi, penyedia trunking SIP, PBX SIP seperti Asterisk, telepon SIP, softphones berbasis SIP, dan aplikasi WebRTC.
Sangat dianjurkan untuk memasang dan mengkonfigurasi proksi SIP sebelum mencoba konfigurasi PBX SIP. Proksi SIP menormalkan banyak lalu lintas yang mencapai PBX dan menyediakan konektivitas dan ketahanan yang lebih besar.
11.8.3.1. Memasang proksi SIP
Install the kamailio package and the package for the database backend, the Falcot administrators chose MySQL, so they install mariadb-server. /etc/kamailio/kamctlrc
is the configuration file for the control tools kamctl
and kamdbctl
. You need to edit and set the SIP_DOMAIN
to your SIP service domain and set the DBENGINE
to MySQL, another database backend can be used.
[...]
## your SIP domain
SIP_DOMAIN=sip.falcot.com
## chrooted directory
# $CHROOT_DIR="/path/to/chrooted/directory"
## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE
# by default none is loaded
#
# If you want to setup a database with kamdbctl, you must at least specify
# this parameter.
DBENGINE=MYSQL
[...]
Now we focus on the configuration file /etc/kamailio/kamailio.cfg
. Falcot needs user authentication and persistent user location, so they add the following #!define
directives at the top of that file:
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v5.2 - default configuration script
# - web: https://www.kamailio.org
# - git: https://github.com/kamailio/kamailio
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB
[...]
Kamailio needs a database structure that we can create running kamdbctl create
as root.
Finally, we can add some users with kamctl
.
#
kamctl add roland secret_password
Once everything is properly configured you can start or restart the service with
systemctl restart kamailio
, you can connect with a SIP client providing the IP address and the port (5090 is the default port). The users have the following id:
roland@sip.falcot.com
, and they can login using a client (see
Bagian 13.10, “Perangkat lunak Komunikasi Real-Time”)
Suatu server XMPP mengelola konektivitas antara pengguna XMPP lokal dan XMPP pengguna di domain lainnya di Internet.
Prosody adalah server XMPP populer yang beroperasi secara andal pada server Debian.
11.8.4.1. Pasang server XMPP
Install the prosody package.
Tinjau berkas konfigurasi /etc/prosody/prosody.cfg.lua
. Yang paling penting untuk dilakukan adalah memasukkan JID pengguna yang diizinkan untuk mengelola server.
admins = { "joe@falcot.com" }
Berkas konfigurasi individu juga diperlukan untuk setiap domain. Salin contoh dari /etc/prosody/conf.avail/example.com.cfg.lua
dan gunakan sebagai titik awal. Berikut adalah falcot.com.cfg.lua
:
VirtualHost "falcot.com"
enabled = true
ssl = {
key = "/etc/ssl/private/falcot.com-key.pem";
certificate = "/etc/ssl/public/falcot.com.pem";
}
-- Set up a MUC (multi-user chat) room server on conference.example.com:
Component "conference.falcot.com" "muc"
Untuk mengaktifkan domain, harus ada symlink dari /etc/prosody/conf.d/
. Buat dengan cara:
#
ln -s /etc/prosody/conf.avail/falcot.com.cfg.lua /etc/prosody/conf.d/
Jalankan ulang layanan menggunakan konfigurasi baru.
11.8.4.2. Mengelola server XMPP
Beberapa operasi manajemen dapat dilakukan dengan menggunakan utilitas baris perintah prosodyctl
. Misalnya, untuk menambahkan akun administrator yang ditentukan dalam /etc/prosody/prosody.cfg.lua
:
# prosodyctl adduser joe@falcot.com
11.8.5. Menjalankan layanan pada port 443
Beberapa administrator lebih suka untuk menjalankan semua layanan RTC mereka pada port 443. Ini membantu pengguna untuk menyambung dari lokasi terpencil seperti Hotel dan Bandara dimana port lain dapat diblokir atau lalu lintas Internet disalurkan melalui server proksi HTTP.
Untuk menggunakan strategi ini, setiap layanan (SIP, XMPP, dan TURN) membutuhkan alamat-alamat IP yang berbeda. Semua layanan masih bisa diwadahi pada host yang sama karena Linux mendukung beberapa alamat IP pada satu host. Nomor port, 443, harus ditentukan di berkas konfigurasi untuk setiap proses dan juga di record SRV DNS.
11.8.6. Menambahkan WebRTC
Falcot ingin membiarkan pelanggan membuat panggilan telepon secara langsung dari situs web. Para administrator Falcot juga ingin menggunakan WebRTC sebagai bagian dari rencana pemulihan bencana, sehingga staf dapat menggunakan peramban web di rumah untuk log masuk ke sistem telepon perusahaan dan bekerja secara normal dalam keadaan darurat.
WebRTC is a rapidly evolving technology and it is essential to use packages from the Testing distribution. Another option is to compile the software.
WebRTC uses a simple API to provide browsers and mobile applications with RTC, it is free software and it is being developed by Google.
A very flexible approach is using GStreamer's WebRTC implementation. It enables pipeline-based multimedia applications, which allows developing interesting and highly efficient applications. A good starting point is the following demo by Centricular, the main company that is developing it:
More advanced click-to-call web sites typically use server-side scripting to generate the
config.js
file dynamically. The
DruCall source code demonstrates how to do this with PHP.
Bab ini mencuplik hanya sebagian kecil dari perangkat lunak server yang tersedia; namun, sebagian besar layanan jaringan umum telah digambarkan. Sekarang saatnya untuk bab yang bahkan lebih teknis: kita akan pergi ke detail yang lebih untuk beberapa konsep, menggambarkan penyebaran besar-besaran, dan virtualisasi.