Product SiteDocumentation Site

11.8. リアルタイムコミュニケーションサービス

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 と XMPP はどちらも同じ機能を持っています。SIP は音声と動画用としてよく知られています。これに対して XMPP は伝統的に IM プロトコル用と考えられています。しかし実際のところ SIP と XMPP のどちらを使っても音声、動画、IM サービスを提供することが可能です。ただし、さまざまな方法で接続できるようにするためには SIP と XMPP の両方を同時に運用することを推奨します。
These services rely on X.509 certificates both for authentication and confidentiality purposes. See 第 10.2 節「X.509 certificates」 for more information.

11.8.1. RTC サービス用の DNS 設定

RTC services require DNS SRV and NAPTR records. A sample configuration that can be placed in the zone file for falcot.com (see also 例 10.13「/etc/bind/db.falcot.com の抜粋」:
; すべてのサービスが実行されるサーバ
server1            IN     A      198.51.100.19
server1            IN     AAAA   2001:DB8:1000:2000::19

; 一部の TURN クライアントは IPv6 の取り扱いにバグがあるので TURN サービスは IPv4 アドレスのみ
turn-server        IN     A      198.51.100.19

; SIP サービス用の IPv4 と IPv6 アドレス。
sip-proxy          IN     A      198.51.100.19
sip-proxy          IN     AAAA   2001:DB8:1000:2000::19

; XMPP サービス用の IPv4 と IPv6 アドレス。
xmpp-gw            IN     A      198.51.100.19
xmpp-gw            IN     AAAA   2001:DB8:1000:2000::19

; STUN と TURN サービス用の DNS SRV および NAPTR レコード
_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.

; SIP サービス用の DNS SRV および NAPTR レコード
_sips._tcp  IN SRV    0 1 5061 sip-proxy.falcot.com.
@           IN NAPTR  10 0 "s" "SIPS+D2T" "" _sips._tcp.falcot.com.

; XMPP サーバとクライアント用の DNS SRV レコード
_xmpp-client._tcp  IN     SRV    5 0 5222 xmpp-gw.falcot.com.
_xmpp-server._tcp  IN     SRV    5 0 5269 xmpp-gw.falcot.com.

11.8.2. TURN サーバ

TURN は NAT ルータの背後にいるクライアントを助けるサービスです。さらに TURN は他のクライアントと通信するための最も適切な方法、直接のメディアパスが見つからない状態でメディアストリームを中継するための最も適切な方法を発見するファイアウォールでもあります。エンドユーザに提供する RTC サービスをインストールする前に TURN サーバをインストールすることを強く推奨します。
TURN とそれに関連する ICE プロトコルはオープン標準です。TURN および ICE プロトコルからの恩恵を受け、数多くの接続方法を提供してユーザの不満を低減するには、すべてのクライアントソフトウェアが ICE および TURN をサポートしている点を確認することが重要です。
ICE アルゴリズムを効果的に動作させるには、サーバが 2 種類の公開 IPv4 アドレスを持つ必要があります。
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 turnserver from the coturn package. We want the server to be an automatically started system service. This is the default behavior using systemd. Only when using the older SysVinit you have to 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. SIP プロキシサーバ

SIP プロキシサーバはさまざまな組織、SIP トンネルプロバイダ、Asterisk などの SIP PBX、SIP フォン、SIP を使うソフトフォン、WebRTC アプリケーションなどの間での SIP 接続の着信および発信を管理します。
SIP PBX のセットアップを試みる前に SIP プロキシをインストールおよび設定することを強く推奨します。SIP プロキシは PBX に到達する数多くのトラフィックを正常化し、高い接続性能と復元性能をもたらします。

11.8.3.1. SIP プロキシのインストール

Install the kamailio package and the package for the database backend. The Falcot administrators chose MySQL, so they install kamailio-mysql-modules and 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.
# kamdbctl create
[...]
# 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 第 13.9 節「リアルタイムコミュニケーションソフトウェア」).

11.8.4. XMPP サーバ

XMPP サーバはローカル XMPP ユーザと公開インターネット上の他のドメインに所属する XMPP ユーザの間の接続を管理します。
prosody is a popular XMPP server that operates reliably on Debian servers.

11.8.4.1. XMPP サーバのインストール

Install the prosody package.
次に /etc/prosody/prosody.cfg.lua 設定ファイルを検査します。ここではサーバを管理することを許可するユーザの JID を書き込むことを忘れないでください。
admins = { "joe@falcot.com" }
また、各ドメインに対する設定ファイルも必要です。/etc/prosody/conf.avail/example.com.cfg.lua からサンプルをコピーして、これを足掛かりとして使ってください。以下は falcot.com.cfg.lua の例です。
VirtualHost "falcot.com"
        enabled = true
        ssl = {
                key = "/etc/ssl/private/falcot.com.key";
                certificate = "/etc/ssl/certs/falcot.com.pem";
                }

-- Set up a MUC (multi-user chat) room server on conference.example.com:
Component "conference.falcot.com" "muc"
falcot.com ドメインを有効化するには、このファイルへのシンボリックリンクを /etc/prosody/conf.d/ の中に作ってください。これを行うには以下のコマンドを実行します。
# ln -s /etc/prosody/conf.avail/falcot.com.cfg.lua /etc/prosody/conf.d/
その後、新しい設定を使ってサービスを再起動します。

11.8.4.2. XMPP サーバの管理

Some management operations can be performed using the prosodyctl command line utility. For example, to add the administrator account specified in /etc/prosody/prosody.cfg.lua:
# prosodyctl adduser joe@falcot.com
See the Prosody online documentation for more details about how to customize the configuration.

11.8.5. ポート 443 番でサービスを実行する

すべての RTC サービスをポート 443 番で実行したいと思う管理者がいるかもしれません。こうすることで、他のポートがふさがれていたり HTTP プロキシサーバを通じてインターネットトラフィックをルーティングしているような、ホテルや空港などのリモート場所から接続するユーザを受け入れることが可能になります。
この方針を採用する場合、それぞれのサービス (SIP、XMPP、TURN) に別々の IP アドレスを設定する必要があります。しかし、すべてのサービスは同じホスト上で運用することが可能です。なぜなら Linux は 1 台のホスト上で複数の IP アドレスを取り扱うことが可能だからです。この場合、それぞれのサービスに対する設定ファイルおよび DNS SRV レコードの中でポート番号 (今回の場合 443 番) を指定しなければいけません。

11.8.6. WebRTC の追加

Falcot は顧客がウェブサイトから電話をかけることができるようしたいと思っています。また Falcot の管理者は障害復旧策の一部として WebRTC を使いたいと思っています。こうすることでスタッフは自宅からウェブブラウザを使って会社の電話システムにログインし、緊急時にも通常と同じ環境で作業を行うことが可能になります。
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.
この章では、利用できるサーバソフトウェアのうちのほんのわずかなソフトウェアだけに注目しました。しかしながら、ほとんどの一般的なネットワークサービスについて言及しました。今や、より技術的な章に入る準備が整ったと言えます。具体的に言えば、一部の概念に関してより詳細を解説し、大規模な配備と仮想化について説明します。