Rtpengine

From 탱이의 잡동사니
Jump to: navigation, search

Overview

RTPEngine 내용 정리.

Basic

RTPEngine 은 RTP media stream proxy 서버이다.

Installation

Required packages

pkg-config
GLib including GThread and GLib-JSON version 2.x
zlib
OpenSSL
PCRE library
XMLRPC-C version 1.16.08 or higher
hiredis library
gperf
libcurl version 3.x or 4.x
libevent version 2.x
libpcap
libsystemd
spandsp
MySQL or MariaDB client library (optional for media playback and call recording daemon)
libiptc library for iptables management (optional)
ffmpeg codec libraries for transcoding (optional) such as libavcodec, libavfilter, libswresample
bcg729 for full G.729 transcoding support (optional)

추가적으로 다음의 패키지들도 필요하다.

libconfig-tiny-perl
module-assistant
libxmlrpc-c++8-dev
linux-*-$(uname -r)

때때로 아래와 같은 에러가 나오면서 실행이 안되는 경우가 있는데, 이럴땐, linux-*-$(uname -r) 패키지 설치 후 다시 빌드를 진행하면 해결된다.

[1581510173.595075] ERR: FAILED TO CREATE KERNEL TABLE 0 (No such file or directory), KERNEL FORWARDING DISABLED
[1581510173.595925] CRIT: Fatal error: Failed to open UDP control connection port

Kernel Module

The kernel module supports multiple forwarding tables which are identified through their ID number. By default, up to 64 forwarding tables can be created and used, giving them the ID numbers 0 through 63.

Each forwarding table can be thought of a separated proxy instance. Each running instance of the rtpengine daemon controls one such table, and each table can only be controlled by one running instance of the daemon at any given time. In the most common setup, there will be only a single instance of the daemon running and there will be only a single forward table in use, with ID zero.

The kernel module can be loaded with the command.

$ modprove xt_RTPENGINE

With the module loaded, a new directory will appear in /proc, namely /proc/rtpengine/. After loading, the directory will contain only two pseudo-fils, control and list. The control file is write-only and is used to create and delete forwarding tables, while the list file is read-only and will produce a list of currently active forwarding tables. With no tables active, it will produce an empty output.

The control pseudo-file supports to commands, add and del, each followed by the forwarding table ID number. To manually create a forwarding. table with ID 42, the following command can be used.

$ echo 'add 42' > /proc/rtpengine/control

After this, the list pseudo-filie will produce the single line 42 as output. This will also create a directory called 42 in /proc/rtpengine/, which contains additional pseudo-files to control this particular forwarding table.

To delete this forwarding table, the command 'del 42' can be issued like above. This will only if no rtpengine daemon is currently running and controlling this table.

Each subdirectory /proc/rtpengine/$ID/ corresponding to each forwarding table contains the pseudo-files blast, control, list and status. The control file is write-only while the others are read-only. The control file will be kept open by the rtpengine daemon while it's running

Control scripts

rtpengine-ctl

$ ./rtpengine-ctl

    rtpengine-ctl [ -ip <ipaddress>[:<port>] -port <port> ] <command>

    Supported commands are:

    list [ numsessions | maxsessions | maxopenfiles | sessions [ <callid> | all | own | foreign ] | totals | loglevel ]
         numsessions           : print the number of sessions
         maxsessions           : print the number of allowed sessions
         maxopenfiles          : print the number of allowed open files
         sessions <callid>     : print detail about one session
         sessions all          : print one-liner all sessions information
         sessions own          : print one-liner own sessions information
         sessions foreign      : print one-liner foreign sessions information
         totals                : print total statistics
         timeout               : print timeout parameter
         silenttimeout         : print silent-timeout parameter
         finaltimeout          : print final-timeout parameter
         loglevel              : print current log level
         redisallowederrors    : print redis-allowed-errors parameter
         redisdisabletime      : print redis-disable-time parameter
         redisconnecttimeout   : print redis-connect-timeout parameter
         rediscmdtimeout       : print redis-cmd-timeout parameter
         controltos            : print control-tos parameter

    get                        : get is an alias for list, same parameters apply

    terminate [ <callid> | all | own | foreign ]
         <callid>              : session is immediately terminated
         all                   : terminates all current sessions
         own                   : terminates own current sessions
         foreign               : terminates foreign current sessions

    set [ maxsessions <int> | maxopenfiles <uint> | timeout <uint> | silent_timeout <uint> | final_timeout <uint> | loglevel <uint> ]
         maxsessions  <int>    : set the max nr of allowed sessions
         maxopenfiles <uint>   : set the max nr of allowed open files
         timeout <uint>        : set the --timeout parameter
         silenttimeout <uint>  : set the --silent-timeout parameter
         finaltimeout <uint>   : set the --final-timeout parameter
         loglevel <uint>       : set the log level to new value (1-7)
         redisallowederrors    : set the --redis-allowed-errors parameter
         redisdisabletime      : set the --redis-disable-time parameter
         redisconnecttimeout   : set the --redis-connect-timeout parameter
         rediscmdtimeout       : set the --redis-cmd-timeout parameter
         controltos            : set the --control-tos parameter

    params [ start | current | diff ]
         start                 : lists the initial values of all the configuration file parameters
         current               : lists the present values of all the configuration file parameters
         diff                  : compares initial and present values of all the configuration file parameters and lists the updated parameters
         revert                : reverts the values of all the configuration file parameters to their initial values

    ksadd [ keyspace <uint>]
         keyspace <uint>       : subscribe to 'keyspace' database

    ksrm [ keyspace <uint>]
         keyspace <uint>       : unsubscribe to 'keyspace' database
                               : remove all foreign calls for that 'keyspace'

    kslist                     : print all currently subscribed keyspaces


    Return Value:
    0 on success with output from server side, other values for failure.

See also