Skip to main content

Posts

Showing posts from 2012

How to compute or validate the network bandwidth when using Speex

This is a quite simple computation or validation of the network bandwidth, but can be tricky if you don't take into account the "quality" parameter used in Speex . Speex is designed to change bitrate depending on the desired quality, and there are 10 different levels of quality per type (narrowband (8 KHz), wideband (16 KHz), ultra-wideband (32 KHz)). All you have to do is take the expected encoding bitrate for that quality ( e.g. 28 Kbps for wideband at quality 8/10 ), compute the payload per frame, optionally sum the payload when you have more than 1 frame per packet, add the overhead of IP, UDP and RTP, then recompute the overall bitrate. Each Speex frame has 20 msec duration. The payload for Speex wideband at quality 8 (28 kbps) is: P = (28*10^3 kbps * 20*10^-3 msec/frame) = 70 B/frame Consider 1 frame per packet and add the overhead from IP, UDP and RTP: Ptot = 70 B + 40 B = 110 B/packet Compute the final network bandwidth: BW = (110 B)*8 / (20 * 10^...

ejabberd clustering: a clever idea for Mnesia replication setup

The process of configuring a cluster of ejabberd entities serving the same domain is apparently simple (considering the  ejabberd Installation and Operation Guide ). Assuming you have a node running, you create a second node with the same Erlang cookie, then setup Mnesia replication between the two. Assuming both ejabberd instances have a similar configuration setup and can connect to each other over the network, you're pretty much done. This can be generalized and made N times to build your cluster. ejabberd uses Mnesia as its internal DB. Although you can easily move to MySQL as storage backend, it's important to note that  Mnesia is still necessary to successfully build the cluster. ejabberdctl is the control script that can be used to start, stop, restart ejabberd. It can be also used to attach a debug console to a running ejabberd instance, or execute any command exposed by an ejabberd module. The idea presented in Easy ejabberd clustering procedure is to exte...

Check the table size of a MySQL DB

I wanted to create a MySQL dump of a small DB, so run  mysqldump  and realized that what I was expecting to take a few MB was instead half a GB. Where did things go wrong? Which table is storing such an unexpected amount of data? Googling around I've found a few interesting posts on how to check the size of a table, and then selected  this one . My suggested approach is: SELECT TABLE_NAME , table_rows , data_length , index_length , round ( ( ( data_length + index_length ) / 1024 / 1024 ) , 2 ) "Size in MB" FROM information_schema . TABLES WHERE table_schema = "schema_name" ; where schema_name is the DB you're interested in. I've then immediately spotted the "offending" table :-)

debian - Managing maintainer scripts for packages with multple .debs

If you've ever installed a package from command line on Linux, you must have noticed two main prompts related to package configuration: one asking what to do with installed configuration files with local changes, and one providing feedback right after the installation/upgrade/removal/purge has completed. Under Debian the latter was most probably the postinst script, one of the Package Maintainer Scripts which is executed after installation and configuration. These diagrams are very useful to understand what happens to the Maintainer Scripts in different circumstances: first installation, upgrade, removal, purge. Their name is probably self-explanatory: preinst , postinst , prerm , postrm . Each of them takes zero or more arguments depending on the scenario. It can help to understand that those are really just scripts executed by dpkg - and typically they are shell scripts, sometimes with interactive prompts. If you're building your own packages, you surely already h...

CANCELing a call - Trip-wires for the SIP fans

SIP is a relatively simple, text-based, human readable protocol that is now the standard de facto for VoIP signalling. The protocol though (in my opinion!) is a little tricky, where typically the tricks are: details . In this first post of a series of "Trip-wires for the SIP fans", I'll talk about CANCEL. The main concept is easy: a caller may decide to cancel a call before this is answered. To do this, it sends a CANCEL request to the called party. What's important to know is that: A CANCEL request relates to an INVITE request, and does not relate to the SIP dialog the request may have created (or will create). For this reason the To header tag must be the same as the INVITE request, even if meanwhile there's been a provisional response to the INVITE creating a dialog (e.g. a 180 with a tag in the To header). From RFC 3261, 9.1 : The following procedures are used to construct a CANCEL request.  The    Request-URI, Call-ID, To, the numeric part of ...

Script vs Program - A pragmatic view

First, it'd be useless to talk about the distinction between a "scripting language' and a 'programming language', because it's clear that the same language can be used in different contexts and environments, be interpreted in some cases or compiled in others. The only distinction worth discussing in my opinion is whether a portion of source code is a script or a program . A very easy conclusion can be found in "Building Skills in Python", S. F. Lott: The “scripting” distinction is an operational feature of POSIX-compliant operating systems. Files which begin with the ‘#!/path/to/interpreter’ will be used as scripts by the OS. They can be executed from the command-line because the interpreter is named in the first line of the file. Languages like Java, C and C++ do not have this feature; these files must be compiled before they can be executed. So what happens if you have, say, a couple of thousands lines of Perl code, distributed in ...

A Practical Approach to the RSA Algorithm

So you're curious about the RSA algorithm, you like Internet technologies and mathematics? This is a short article on how the RSA Algorithm works, with practical examples. Preface and Disclaimer Obviously the article itself and the code here presented are suitable for a learning activity only and in case you use them, you do it at your own responsibility. I based this on the 1977's article from Rivest, Shamir and Adleman , (from which initial letters the algorithm takes the name), and ran the code on a Mac with python 2.6.1. The code presented here is also not optimized. The reader is invited to suggest better implementations (in languages other than python as well). Mathematics concepts you need to know - What a 'prime number' is. (A integer number which can be divided evenly only by 1 and itself. e.g. 1, 2, 3, 5, 7, 11, ..., 47, ...) - What the 'modulus' (here referred as 'mod') operation is. ('A mod B' is the reminder of A divided...