This version of sip-mbus requires Windows NT 4.0, Solaris or Linux and some external programs.
- Tcl/Tk 8.4a1
- RAT 4.2.12
- gcc compatible compiler
- Tcl?Tk 8.4a1
- RAT 4.2.12
- Visual C++
This explain is for Unix compatible O/S. In Windows compatible O/S, Visual C++ can be used.
When rat-4.2.12.tar.gz is extracted from the archive, it makes four directories, common, rat, tcl-8.0 and tk-8.0. common directory contains mbus library source code. The patch directory has two files (rtp.c and rtp.h) in common directory and they should be overwritten and then compile them.
$ cp patch/common/* $(RAT-DIRECTORY)/common
$ ./configuration
$ make
tcl-8.0 and tk-8.0 directories have tcl/tk source code for mbus library engines, media and user interface of RAT.
$ ./configuration
$ make
rat directory have source code for controller, engine and user interface for RAT. The patch directory has two files (mbus_engine.c and ui_audiotool.tcl) which need to be overwritten. They were added to process rtp.addr.change mbus command.
$ cp patch/rat/* $(RAT-DIRECTORY)/rat
$ ./configuration
$ make
In Unix:
$make /f makefile.unix
This command will make several directories which are obj for object files and unix for library files. The test programs are in the test directory.
sip-mbus interface
sip-mbus interface Description sipc_mbus_control NAME sipc_mbus_control - initialize the mbus library
SYNOPSIS
#include "sip_mbus_control.h"
int sipc_mbus_control(ClientData dummy, Tcl_Interp *interp, int argc, char **argv);
The sipc_mbus_control() function provides for initialization of mbus library.
The argv[1] argument is NULL.
sip_mbus_rtp_addr NAME sip_mbus_rtp_addr - change the remote IP address, src/dst port number and ttl of RAT
SYNOPSIS
#include "sip_mbus_control.h"
int sipc_mbus_rtp_addr(ClientData dummy, Tcl_Interp *interp, int argc, char **argv);
The sipc_mbus_rtp_addr() function provides for control over IP address, port number and ttl.
The sipc_mbus_rtp_addr takes four arguments.
- argv[1] remote IP address
- argv[2] source port number
- argv[3] destination port number
- argv[4] time-to-live
sipc_mbus_talk NAME sipc_mbus_talk - enable/disable of talk
SYNOPSIS
#include "sip_mbus_control.h"
int sipc_mbus_talk(ClientData dummy, Tcl_Interp *interp, int argc, char**argv);
The sipc_mbus_talk() function enables or disables of talk of RAT.
The sipc_mbus_talk takes one argument.
- argv[1] 0: talk, 1: mute
sipc_mbus_codec NAME sipc_mbus_codec - changes the codec
SYNOPSIS
#include "sip_mbus_control.h"
int sipc_mbus_codec (ClientData dummy, Tcl_Interp *interp, int argc, char**argv);
The sipc_mbus_codec () function changes the codec of RAT to encode.
The sipc_mbus_codec takes one argument.
- argv[1]
- l16: Linear 16, 128 kbit/s: Uncompressed 16 bit samples
- pcma: A-Law, 64 kbit/s: a-law companded 8 bit samples
- pcmu: Mu-Law, 64 kbit/s: mu-law companded 8 bit samples.
- dvi: DVI-ADPCM, 32 kbit/s: 16 bit samples.
- gsm: GSM, 13.2 kbit/s:
- lpc: LPC, 5.8 kbit/s
sipc_mbus_packetization NAME sipc_mbus_codec - sets the number of codec frames
SYNOPSIS
#include "sip_mbus_control.h"
int sipc_mbus_codec (ClientData dummy, Tcl_Interp *interp, int argc, char**argv);
The sipc_mbus_codec () function sets the number of "units" (codec frames, typically) placed in each packet when transmitting.
The sipc_mbus_codec takes one argument.
- argv[1]: units: 1, 2, 4 or 8
Program internal operation
sipc should spawn sip-mbus controller (sip_mbus_control.c) to send and receive mbus command to and from RAT before it uses mbus library (mbus_control.c). The sip-mbus controller not only sends mbus.hello mbus command as a heartbeat message every second to indicate liveness, but also receives mbus.hello of other mbus engines.
![]()
sipc_mbus_control
This function should be called before other mbus-controller function calls because this initialize the mbus library. sipc_mbus_control calls sip_mbus_control() function which initializes the mbus library and sends mbus.hello command and receives it periodically.
![]()
void sip_mbus_control () {
/* create the mbus address of sip-mbus controller */
/* initialization of mbus library */
mbus_init(mbus_control_rx, mbus_err_handler, c_addr);
while (true) {
/* send mbus.hello command */
mbus_send(m);
/* mbus handler process the received mbus command */
mbus_recv(m, m, &timeout);
}
}
sip_mbus_rtp_addr
sipc sends rtp.addr.change mbus command calling rtp_addr_change() of sip-mbus controller to change remote IP address, src/dst port number and ttl. Before it sends the command, it should encode them using mbus_encode_str() function. This command should be sent to the mbus_engine of RAT. If this command is being sent to user interface or controller of RAT, they will be exit abnormally.
![]()
mbus_qmsgf (mbus, addr_rat_engine, reliable, mbus_command, "%s %d %d %d", ip_addr, src, dst, ttl);
mbus: mbus library
addr_rat_engine: the mbus address of the mbus engine of RAT
reliable: TRUE or FALSE
mbus_command: rtp.addr.change mbus command
arguments: encoded string of "ip-addr src_port dst_port ttl".
sipc_mbus_talk, sipc_mbus_codec and sipc_mbus_packetization
All procedure is similar to rtp_addr_change() function except using different mbus commands.
sipc_mbus_talk: audio.input.mute
sipc_mbus_codec: tool.rat.codec
sipc_mbus_packetization: tool.rat.rate
In order to provide the functionality of address change for RAT, some mbus library files and RAT source files are changed.
mbus library files
- rtp.h
int rtp_addr_change(char *addr, uint16_t rx_port, uint16_t tx_port, int ttl, struct rtp *session);
- rtp.c
Some assert line should be commented out, because when the remote IP address, src/dst port number and ttl is changed, RAT checks whether the session exists. If any, it regards this cast as an error. But in our architecture, we need to change them in session.
static void check_database(struct rtp *session)
{
......
......
//assert(session != NULL);
//assert(session->magic == 0xfeedface);
test = session -> ssrc_count;.....
}rtp_addr_change() function is added to allow sipc to change some configuration. This function substitutes addr, rx_port, tx_port and ttl fields for the new values received from sipc.
int rtp_addr_change(char *addr, uint16_t rx_port, uint16_t tx_port, int ttl, struct rtp *session) {
session->addr = xstrdup(addr);
session->rx_port = rx_port;
session->tx_port = tx_port;
session->ttl = min(ttl, 127);
free(session->rtp_socket);
session->rtp_socket = udp_init_if(addr, (char *)NULL, rx_port, tx_port, ttl);
session->rtcp_socket = udp_init_if(addr, (char *)NULL, (uint16_t) (rx_port+1), (uint16_t) (tx_port+1), ttl);
// in future use, now just return 1(OK)
return 1;
}
RAT source files
This static table maps the mbus command rtp.addr.change to rx_rtp_addr_change() function. When mbus engine of RAT receive rtp.addr.change mbus command, it calls rx_rtp_addr_change() function, which uses rtp_addr_change() function in mbus library.
static const mbus_cmd_tuple engine_cmds[] =
{ .....
{"rtp.addr.change",rx_rtp_addr_change },
.....
static void rx_rtp_addr_change(char *srce, char *args, session_t *sp)
{
/* rtp.addr.change ("224.1.2.3" 1234 1234 16) */
char *addr;
int rx_port, tx_port, ttl;
int result;
struct mbus_parser *mp;
UNUSED(srce);
mp = mbus_parse_init(args);
mbus_parse_str(mp, &addr); addr = mbus_decode_str(addr);
mbus_parse_int(mp, &rx_port);
mbus_parse_int(mp, &tx_port);
mbus_parse_int(mp, &ttl);
mbus_parse_done(mp);
result = rtp_addr_change(addr, (uint16_t)rx_port, (uint16_t)tx_port, ttl, (struct rtp *)sp->rtp_session[0]);
}
This file is related to user interface of RAT. If it receive rtp.addr.change mbus command, it updates the user interface using this procedure.
proc mbus_recv_rtp.addr.change {addr rx_port tx_port ttl} {
global session_address group_addr
set group_addr $addr
set session_address "Address: $addr Port: $rx_port TTL: $ttl"
}
The test directory contains two test programs. The test1.tcl uses hard coded values of the parameters and just tests whether mbus library works. The test2.tcl provides the user interface to get user input for RAT. Please be sure RAT execution before the test program.
$test1.tcl
This test program check out the working of the sip-mbus controller.
$test2.tcl
Tk interface is provided to get user input for remote IP address, codec, mute/talk parameter and packetization values.
When RAT executes, the following figure shows that the remote IP address is "128.59.15.51", source/destination port numbers are 23456, mute of talking and ttl is 15.
![]()
All source files are sip-mbus.tar except RAT related files. RAT can be downloaded at Reliable Audio Tool (RAT)
Last updated 02/16/01