<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD Docbook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<chapter id="node-1386">
<chapterinfo>
<releaseinfo>
md5-hash:4687c7b3dc9018599360eb992adc5657
weight:0
depth:2
</releaseinfo>
</chapterinfo>
<title>Install</title>
<literallayout><![CDATA[Unpack to patch-o-matic-ng directory and pom2patch utility.<!--break---><h2 id="opus">xt_RTPPROXY.ko</h2>

<p cc="cc" />kernel module, rtp sessions, sockopt interface for session manipulation,statistics

<p cc="cc" />1) compile kernel module<pre>  make  make modules_install install</pre>

<p cc="cc" />2) load module<pre>  su -  modprobe -i xt_RTPPROXY</pre>

<p cc="cc" />3) list if module loaded<pre>  lsmod</pre>

<p cc="cc" />4) check kernel log in case or problem<pre>  dmesg</pre><h2 id="opus">libipt_RTPPROXY.so</h2>

<p cc="cc" />extensions for iptables, connecting to .ko using control socket, requiresroot but rights may be limited by capabilities (CAP_NET_ADMIN,CAP_NET_RAW).See iptrtpproxy.8 manpages

<p cc="cc" />Library provides API fow RTP session manipulation.

<p cc="cc" />1) compile

<p cc="cc" />2) prepare iptables

<p cc="cc" /><pre># define IPexport RTP_IP=1.1.1.1export RTP_PORT=50000

<p cc="cc" /># in case of non standard iptables libraries locationexport IPTABLES_LIB_DIR=<em id="opus">pwd</em>/extensions

<p cc="cc" /># define switchboard as custom mangle chain#define new _mangle_ chain called my_rtpproxyiptables -t mangle -N my_rtpproxy

<p cc="cc" /># identify switchboard, target is RTPPROXY# we must define ip,port and max.number off sessions# if RTPPROXY does not matches udp protocol and switchboard then chain# continuesiptables -t mangle -A my_rtpproxy -j RTPPROXY --addr-a $RTP_IP --port-a $RTP_PORT --max-sess 250 -p udp

<p cc="cc" /># specify conditions to call custom chain, -p udp, address, port# we must call chain in PREROUTING, POSTROUTING and OUTPUT# prerouting changes destination address for proxied ports (RTP)iptables -t mangle -A PREROUTING -j my_rtpproxy# change source address, replies goes back through itiptables -t mangle -A POSTROUTING -j my_rtpproxy# do it also for locally generated/targeted packetes# non necessary when RTP client is not allowed proxy machine, it's probableiptables -t mangle -A OUTPUT -j my_rtpproxyiptables -t mangle -A INPUT -j my_rtpproxy

<p cc="cc" /># list mangle chainsiptables -t mangle -L

<p cc="cc" /># enable UDP forwardingiptables -I FORWARD 1 -j ACCEPT -p udp# if local RTP client allowediptables -I INPUT 1 -j ACCEPT -p udpecho "1"> /proc/sys/net/ipv4/ip_forward</pre><h2 id="opus">iptrtpproxy</h2>

<p cc="cc" />utility for RTP session manipulation from command line, uses lib_RTPPROXY,root required. Real SIP router should implement session manipulation(alloc, update, delete) using libipt_RTPPROXY library.

<p cc="cc" />Example related to Alice-Bob call.

<p cc="cc" /><pre># get confing info, uptime, num of switchboards, etc.iptrtpproxy info

<p cc="cc" />iptrtpproxy list --list-switchboard

<p cc="cc" /># allocate session for Aliceiptrtpproxy alloc --addr-a $RTP_IP --port-a $RTP_PORT --rtp-learning-timeout-a 10000 --rtp-addr-a 192.168.1.1 --rtp-port-a 10000 --rtcp-addr-a 192.168.1.1 --rtcp-port-a 10001# we'll get sess_id (=0 for first session) and allocated RTP proxy ports (50000&50500)

<p cc="cc" /># update Bob's addressiptrtpproxy update --addr-a $RTP_IP --port-a $RTP_PORT --sess-id-lo 0 --rtp-addr-b 5.6.7.8 --rtp-port-b 20000 --rtcp-addr-b 5.6.7.8 --rtcp-port-b 20001

<p cc="cc" /># update Alices's NATed addressiptrtpproxy update --addr-a $RTP_IP --port-a $RTP_PORT --sess-id-lo 0 --rtp-addr-a 1.2.3.4 --rtp-port-a 30000 --rtcp-addr-a 1.2.3.4 --rtcp-port-a 35000

<p cc="cc" /># delete sessioniptrtpproxy delete --addr-a $RTP_IP --port-a $RTP_PORT --sess-id-lo 0

<p cc="cc" /># get statisticsiptrtpproxy list</pre><h2 id="opus">RTP client</h2>

<p cc="cc" />netcat for testing purposes

<p cc="cc" /><pre># enable INPUT udp packetsiptables -I INPUT 1 -j ACCEPT -p udp

<p cc="cc" /># netcat RTP clients# Alicenc -u -s 192.168.1.1 -p 10000 1.1.1.1 50000# Bobnc -u -s 5.6.7.8     -p 20000 1.1.1.1 50500</pre>

<p cc="cc" />]]></literallayout>
</chapter>

