Kamailio module

From 탱이의 잡동사니
Revision as of 21:13, 23 July 2019 by Pchero (talk | contribs) (→‎MAXFWD)
Jump to navigation Jump to search

Overview

Kamailio module들 내용 설명

Dispatcher

Kamailio 에서 트래픽 로드 밸런싱을 수행할 수 있는 모듈이다.

ETC

Kamailio 4.4.7 버전에서 이슈가 있었다. 새롭게 Asteri

Dispatcher 모듈에 여러개의 Asterisk IP 가 설정되어 있는 상황에서, 어느 하나의 IP 가 flag 4(Disabled) 로 설정되게 되면 정상적으로 로드 밸런싱을 수행하지 않는 문제가 있었다.

HTABLE

This module adds a hash table container to the configuration language. The hash table is stored in shared memory and the access to it can be done via pseudo-variables: $sht(htname=>name). The module supports definition of many hash tables and can load values at startup from a database table.

RPC Commands

htable.get htable key

Lists one value in a hash table.

Parameters

  • htable: Name of the hash table to dump.
  • key: Key name of the hash table value to dump.

Example

...
# Dump $sht(students=>alice)
kamcmd htable.get students alice

# Dump first entry in array key course $sht(students=>source[0])
kamcmd htable.get students course[0]
...

htable.delete htable key

Delete one value in a hash table.

Parameters

  • htable: Name of the hash table to delete.
  • key: Key name of the hash table value to delete.

Example

...
# Delete $sht(student=>alice)
kamcmd htable.delete students alice

# Delete first entry in array key course $sht(students=>course[0])
kamcmd htable.delete students course[0]

htable.sets htable key value

Set an item in hash table to string value.

Parameters

  • htable: Name of the hash table.
  • key: Key name in the hash table.
  • value: String value for the item.

Example

...
# Set $sht(test->x) as string
kamcmd htable.sets test x abc

# Set first entry in array key x $sht(test=>x[0]) as string
kamcmd htable.sets
...

htable.seti htable key value

Set an item in hash table to integer value.

Parameters

  • htable: Name of the hash table.
  • key: Key name in the hash table.
  • value: Integer value for the item.

Example

...
# Set $sht(test=>x) as integer
kamcmd htable.seti test x 123

# Set first entry in array key x $sht(test=>x[0]) as integer
kamcmd htable.seti test x[0] 123

htable.dump htable

Lists all the values in a hash table.

Parameters

  • htable: Name of the hash table to dump.

Example

...
kamcmd htable.dump ipban
...

htable.reload htable

Reload hash table from database

Parameters

  • htable: Name of the hash table to reload.

Example

kamcmd htable.reload ipban

htable.flush htable

Empty the hash table.

Parameters

  • htable: Name of the hash table to flush.

Example

kamcmd htable.flush ipban

htable.listTables

Lists all defined tables.

Example

$ sudo kamcmd htable.listTables
{
	name: ipban
	dbtable: 
	dbmode: 0
	expire: 300
	updateexpire: 1
	size: 256
	dmqreplicate: 0
}

htables.stats

Get statistics for hash tables - name, number of slots, number of items, max number of items per slot, min number of items per slot.

Example

$ sudo kamcmd htable.stats
{
	name: ipban
	slots: 256
	all: 0
	min: 0
	max: 0
}

MAXFWD

Max-Forward SIP header 와 관련된 기능을 수행할 수 있는 모듈이다.

The SIP Max-Forward header is used to prevent loops in a SIP network. Every server that process and forward a SIP request lowers the Max-Forward value with one. When the value reaches zero, the request is not forwarded and an error response is sent to the UAC.

Parameters

max_limit(integer)

Set an upper limit for the max-forward value in the outgoing requests. If the header is present, the decremented value is not allowed this max_limits - if it does, the header value will by decreased to "max_limit". This check is done when calling the maxfwd_process() function.

The range of values stretches from 1 to 256, which is the maximum MAX-FORWARDS value allowed by RFC 3261. The value can be changed at runtime.

Default value is "70"

modparam("maxfwd", "max_limit", 32)

Functions

maxfwd_process(max_value)

If no Max-Forward header is present in the received request, a header will be added having the original value equal with "max_value". If a Max-Forward header is already present, its value will be decremented(if not 0). The parameter can be a variable.

This function can be used from REQUEST_ROUTE.

Variables

  • max_value: Value to be added if there is no Max-Forward header field in the message.

Return code

  • 2 (true): header was not found and a new header was successfully added.
  • 1 (true): header was found and its value was successfully decremented (had a non-0 value).
  • -1(false): the header was found and its value is 0(cannot be decremented).
  • -2(false): error during processing.

The return code may be extensivly tested via script variable "retcode" (or "$?").

...
# initial sanity checks --- messages with
# max_forwards==0, or excessively long requests
if (!maxfwd_process("10") && $retcode==-1) {
  sl_send_reply("483", "Too Many Hops");
  exit;
};
...

mf_process_maxfwd_header(max_value)

Same as maxfwd_process(max_value).

SL

SL 모듈을 이용하면 Kamailio 를 stateless UA server 로 사용할 수 있도록 해준다.

The SL module allows the SIP server to act as a stateless UA server and generate replies to SIP requests without keeping state. That is beneficial in many scenarios, in which you wish not to burden server's memory and scale well.

The SL module needs to filter ACKs sent after a local stateless reply to an INVITE was generated. To recognize such ACKs, Kamailio adds special "signature" in to-tags. This signature is sought for in incoming ACKs, and if included the ACKs are absorbed.

To speed up the filtering process, the module uses a timeout