Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Wednesday, 1 July 2015

Installing FFmpeg in Ubuntu 14.04 from source

Installing FFmpeg  in Debian Ubuntu 14.04 :


Build and install FFmpeg:
cd /usr/local/src
wget -c http://ffmpeg.org/releases/ffmpeg-1.0.2.tar.gz
tar zxvf ffmpeg-1.0.2.tar.gz
cd ffmpeg
./configure --extra-cflags="-fPIC" --extra-ldflags="-lpthread" --enable-pic \
--enable-memalign-hack --enable-shared --disable-static --disable-network \
--disable-protocols --disable-pthreads --disable-devices --disable-filters \
--disable-bsfs --disable-muxers --disable-demuxers --disable-parsers \
--disable-hwaccels --disable-ffmpeg --disable-ffplay --disable-ffserver \
--disable-encoders --disable-decoders --disable-zlib --enable-gpl --disable-debug \
--enable-encoder=h263 --enable-encoder=h263p --enable-decoder=h263 \
--enable-encoder=mpeg4 --enable-decoder=mpeg4 --enable-libx264 \
--enable-encoder=libx264 --enable-decoder=h264
make -j `getconf _NPROCESSORS_ONLN`
make install
ldconfig


Wednesday, 24 June 2015

Asterisk behind the NAT setting

Asterisk behind NAT

The Asterisk Server is behind NAT
The Asterisk server could be on the LAN (or in a DMZ) with a NAT firewall between it and the Internet. When it communicates with external peers or devices, the network connections have to pass through the local NAT device.

The remote device that is connecting to Asterisk is behind NAT
Suppose that your Asterisk server is connected directly to the Internet. Provided your system is made reasonably secure (e.g. through firewall rules) there can be significant benefits in having it directly connected to the Internet. However, you are unlikely to be able to control the networking environment of the devices that connect to it. If remote users have IP phones that register with your Asterisk server, it is very likely that those phones will be behind a NAT device at the far end.

Asterisk is behind one NAT and the remote device is behind another
This is an unattractive situation for Asterisk to handle and should generally be avoided if possible. However, it can be made to work provided suitable NAT traversal solutions are applied at both ends.

When the Asterisk server is behind a local NAT router

Settings within the sip.conf file when you have a static IP address

The externip parameter in sip.conf tells Asterisk what the external IP address is for the NAT/firewall/router. This is the address that external devices on the Internet must use to reach the Asterisk server. If you are unsure what this address is, ask your system administrator or open a web browser on the Asterisk server and point it at
http://whatismyip.com
or
http://www.amibehindnat.com

The externhost parameter in sip.conf may be used to tell Asterisk the external address of your NAT/firewall/router in the form of a FQDN. It is an alternative to externip. You must either use externip or externhost, not both. This parameter is the key to solving the NAT problem if your ISP has not allocated you with a static IP address.

The externrefresh parameter in sip.conf works in conjunction with externhost. It tells asterisk how often to query the host name using DNS. I recommend you set it to a higher value than the default - perhaps 600.

The localnet parameter in sip.conf is used to tell Asterisk which addresses are local. This is important because Asterisk will substitute the value given in externip for its own local address whenever it thinks it is communicating with a remote peer or device. The only way it knows that a device is local, is through the IP address of that device being within the range specified by localnet.

For example:
[general]
externip=63.182.70.1
localnet=192.168.0.0/255.255.255.0
localnet=192.168.2.0/255.255.255.0

Note how you can specify several different subnets using the localnet parameter - simply put each one on a new line.

Settings within the sip.conf file when you have a dynamic IP address

Internet Service Providers normally charge extra to provide one or more static IP addresses - the option may not even be available if you have a domestic rather than a business broadband package. If your public IP address is dynamic (allocated by your provider's DHCP service) then you will still be able to use Asterisk behind your firewall provided it supports automatic registration with a Dynamic DNS service such as DynDNS.com. The basic service is free so it is worth a try. First, you must register with DynDNS.com (or one of the alternative dynamic DNS service providers), then instruct your firewall to use the service and finally you must use the externhost parameter to specify your host name.

Don't use externip, but do specify externrefresh and localnet as described above.

I'm using Trixbox/FreePBX. Where do I set these parameters?
Just edit the file /etc/asterisk/sip_general_custom.conf and put the parameters in there, then restart the asterisk service or reboot the machine.

Settings on the local NAT/firewall/router

If you are unable to make configuration changes (or have changes made on your behalf) on the local NAT/firewall/router device, then you are unlikely to be able to make Asterisk work for SIP connections to remote peers and devices. The suggestions given here assume that you do have access to the configuration rules on this device. If not, consider using the IAX protocol instead.

The NAT/firewall/router should be configured to allow inbound UDP connections to your Asterisk server on the primary SIP port (usually 5060). It must also be configured to allow inbound UDP connections to the same ports on the Asterisk server as are defined in the rtp.conf file. The default port range in rtp.conf is 10000 to 20000. However, it is recommended that the range of port numbers assigned for RTP is reduced by editing rtp.conf, changing the parameter settings and then restarting Asterisk. It will usually be sufficient to have a range that is approximately twice the maximum number of simultaneous calls, plus a few on top for good measure.

When configuring your NAT/firewall/router device, you will probably need to find the settings for "port forwarding" or "one-to-one" NAT. Make sure your NAT device does not use port address translation. i.e. if your Asterisk server expects to receive SIP messages on port 5060, make sure you also use port 5060 on the WAN port of your NAT device to forward these messages. Similarly, make sure the same range of port numbers are forwarded on the WAN port for RTP as will receive the RTP on the Asterisk server.

When the remote devices are behind a NAT router

Settings within the sip.conf file
The nat parameter in sip.conf tells Asterisk that the remote device is behind a NAT router. There are a number of options for this parameter, but the most likely to work with NAT'd remote devices is nat=yes. You should set this parameter for each peer or device in sip.conf - i.e. don't simply use a default setting for all peers and devices unless you fully understand the implications of doing so.

The qualify parameter in sip.conf tells Asterisk to send a kind of ping message to the remote device about every 30 seconds. This can be very helpful when connected to a remote device behind NAT because it forces the NAT router to keep the connection open. Normally, NAT routers will automatically close existing connections if there is no activity on them for more than a preset time. The time that must elapse before a connection is dropped will vary from one manufacturer to another, but it will almost always be more than 30 seconds. It also has a another benefit because it allows Asterisk to know if the connection is still working.

For example:
[peer1]
type=peer
nat=yes
qualify=yes


Checking your remote devices
From the Asterisk CLI (Command Line Interface) type the command "sip show peers". This will report back a list of all peers/devices configured in sip.conf and will show if they have registered successfully. It will also show if they are still reachable provided you specified qualify=yes.

Settings on the remote NAT/firewall/router
Very similar rules apply to the configuration of the remote NAT/firewall/router as those described above for the local firewall. However, the settings on the remote firewall need to be matched to the ports used by the remote device. If the remote device is an IP phone you will ideally want to check the phone's configuration and find out what port numbers it uses for SIP messaging (usually UDP port 5060) and for RTP. Then set port forwarding on the remote firewall for those ports.

Fortunately, the solutions available for remote devices, especially IP phones, are more wide ranging than those available for the Asterisk server. Firstly, most modern IP phones will be able to use a STUN server. This is an incredibly useful option and you should certainly try to switch on STUN on all the remote devices if available. STUN can take advantage of symmetrical RTP sessions on the server (i.e. sessions where the server can receive RTP audio on the same port as it uses to send the RTP audio). This option is enabled on your Asterisk server by setting "nat=yes" as described above. Also, many IP phones will recognise and use other NAT traversal techniques including sending "keep-alive" packets after registration (similar to "qualify=yes").

source : smartvox 

Monday, 22 June 2015

Opensips Nat Handling

Call fix_nat_sdp for INVITE,RE-Invite.. That's it, This route will take care of everything..


route[fix_nat_sdp] {

        if(has_body("application/sdp"))
 {
                xlog("fix_nat_sdp called\n");
                setbflag(3);
                rtpproxy_offer();       
                t_on_failure("1");
        }

 t_on_reply("1");

        if(nat_uac_test("1")){
                fix_nated_contact(); 
        }
}

onreply_route[1] {
        xlog("onreply_route called\n");
        if(nat_uac_test("1")){
                fix_nated_contact(); 
        }

        if(has_body("application/sdp")){
                rtpproxy_answer();
        }
}

Thursday, 18 June 2015

Which Ubuntu Version is equal to which Debian Version

Which Debian Version Ubuntu 14.04 LTS using ?

You can find the Debian version on which your Ubuntu version is based in the file: /etc/debian_version
From 10.04 up to 15.04:
15.04  vivid      jessie / sid
14.10  utopic     jessie / sid
14.04  trusty     jessie / sid
13.10  saucy      wheezy / sid
13.04  raring     wheezy / sid
12.10  quantal    wheezy / sid
12.04  precise    wheezy / sid
11.10  oneiric    wheezy / sid
11.04  natty      squeeze / sid
10.10  maverick   squeeze / sid
10.04  lucid      squeeze / sid
sid is the development distribution of Debian (sid - testing - stable)



Monday, 8 June 2015

How to run Tomcat on port 80 in Ubuntu or Debian

Following works:
First, set AUTHBIND=yes in /etc/default/tomcat7 file
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat7 /etc/authbind/byport/80

Wednesday, 3 June 2015

MWI activation in Polycom phone and Asterisk:

MWI activation in Polycom phone and Asterisk:

#vi /etc/asterisk/voicemail.conf
[default]
57644 => 1234,John Doe, John.Doe@xyz.com

#vi /etc/aterisk/sip.conf
[
57644 ]
type=friend
host=dynamic
username=
57644 
callerid="John Doe" <57644 >
secret=mypassword
mailbox=
57644 

pbx CLI> sip show peer 57644
* Name : 57644
- - - -
- - - -
Mailbox : 57644
Call limit : 0
Max forwards : 0
Dynamic : Yes
Callerid : "John Doe" <57644>
MaxCallBR : 384 kbps
Expire : 205
- - - -
- - - -
Addr->IP : 192.168.2.10:5060
Defaddr->IP : (null)
Prim.Transp. : UDP
Allowed.Trsp : UDP
Reg. exten :
Def. Username: 57644
SIP Options : (none)
Codecs : 0x4 (ulaw)
Codec Order : (ulaw:20)
Auto-Framing : No
100 on REG : No
Status : Unmonitored
Useragent : PolycomSoundPointIP-SPIP_331-UA/3.3.2.0413
Reg. Contact : sip:57644@192.168.2.10


Asterisk automatically sends NOTIFY message to IP phone provided that the phone is registered correctly with Asterisk and Asterisk knows which voicemail box is associated with that extension. You can check that by issuing the asterisk CLI command #sip show peer
Reg. Contact : sip:57644@192.168.2.10 tells you that phone is successfully registered. 
Mailbox : 57644
 tells you that Asterisk knows that voicemail box 57644 is associated with that phone. That association is defined in sip.conf.

Tuesday, 2 June 2015

Sending MP3 Attachments form Asterisk Voicemail.

source : http://bernaerts.dyndns.org/
This guide will explain how to configure Asterisk PBX to send voicemail as email with messages as mp3 attachement.

If, like me, you are using an Asterisk server, you may be using the voicemail by email functionnality. It allows your Asterisk PABX to send your by email all the messages received in your voicemail.
Just imagine :
  • someone is calling you on your landline
  • he is leaving a message on your answering machine
  • after few seconds, you are receiving a mail on your android or i-phone with the message as an attachment
You can call back immediatly or even forward the email for someone else to deal with that call !

One of the main drawback of that functionnality is that Asterisk can generate attachments using only the standard telephony codecs (wav49, gsm, wav). The wav format is widely recognised, but it is quite uncompressed. The wav49 or gsm formats are better in terms of compression, but sadly they are not recognised by all the devices able to deal with your emails.

So why not to use mp3 format for the voicemail attachments ?
This is what this guide is all about. It will explain how to catch the emails sent by Asterisk and convert the audio attachment from a wav file to a mp3 file.
This guide is based on an Asterisk 1.6 version, running under Debian Squeeze.
As it uses only some very basic & standard linux tools, it should be compatible with any Asterisk installation.
It is based on the standard email structure generated by Asterisk.
If you have modify the Asterisk email format, you will need to adjust the script.

1. Principle

The main principles are :
  • Asterisk voicemail is configured to generate some wav attachements (uncompressed, best quality available)
  • Instead of sending the mail to sendmail, Asterisk is configured to send the mail to one specific script
  • This script will do all the job, and finally give back the mail to sendmail
The script will do some ordered tasks :
  1. catch the stream,
  2. analyse the email content,
  3. seperate each mime part,
  4. pullout the audio attachment,
  5. compress it to mp3,
  6. regenerate the mail content,
  7. send it to sendmail as expected
With this approach, you just need some specific configuration on Asterisk side.
From Asterisk side, the emails are just sent thru another emailer, that's it !
Unlike other methods, you don't need any patch for Asterisk.
You are still using a regular Asterisk, available from your distribution.
So, you can apply any standard update.
Any update to a new Asterisk version should remain fully compatible.

2. Install the packages

First thing to do is to install the packages needed by our script (unix2dos, dos2unix & lame).
aptitude install dos2unix lame

3. Setup the main Script

Once these packages are installed, we can generate the script that will do all the job.

As Asterisk generates the mail content, including the wav attachment encoded in base64, the script main job will be to :
  1. get the attachment from the email content
  2. convert it to mp3
  3. regenerate the mail content with new attachment
  4. send the mail thru sendmail
This job will be done with some very basic linux tools like sed, awk, grep, base64, unix2dos, ...

One important thing is to respect the body structure of the mail content, including the LF and CRLF used to separate lines, depending on the different mime parts. In fact, in the mail body genarated by Asterisk, all the lines are separated with LF, with the exception of the base64 coded audio attachment where they are separated with CRLF.
For the mp3 conversion, 2 compression options are available :
  • CBR - Constant Bit Rate compression will create mp3 streams compatible with any device, but the size/quality ratio is not optimised.
  • VBR - Variable Bit Rate is much more efficient in term of file size, but playback has been tested very poor on some smartphones.
The script is providing both the compression parameters, you just need to adjust it to your need.
The detailed phases of the script are as follow :
  1. Creation of a temporary directory, randomly generated, where we will generate all the temporary files
  2. Dumping of the mail content sent by Asterisk in a file
  3. Detection of the boundary pattern which separate the differents mime parts in the mail
  4. With this pattern, cutting of the mail content into mime parts
  5. Decoding of the WAV attachment which is base64 coded (you have to ignore parasite caracters in some configurations)
  6. Compression into mp3 format
  7. Coding of the mp3 audio file back to base64
  8. Re-assembly of the full mail content, using the new mp3 attachment
  9. Sending of the mail thru sendmail
  10. Deletion of the temporary directory
This sendmailmp3 script will be placed side to the sendmail command, under /usr/sbin.
/usr/sbin/sendmailmp3

#! /bin/sh
# Asterisk voicemail attachment conversion script
# Revision history :
# 22/11/2010 - V1.0 - Creation by N. Bernaerts
# 07/02/2012 - V1.1 - Add handling of mails without attachment (thanks to Paul Thompson)
# 01/05/2012 - V1.2 - Use mktemp, pushd & popd
# 08/05/2012 - V1.3 - Change mp3 compression to CBR to solve some smartphone compatibility (thanks to Luca Mancino)
# 01/08/2012 - V1.4 - Add PATH definition to avoid any problem (thanks to Christopher Wolff)

# set PATH
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# save the current directory
pushd .

# create a temporary directory and cd to it
TMPDIR=$(mktemp -d)
cd $TMPDIR

# dump the stream to a temporary file
cat >> stream.org

# get the boundary
BOUNDARY=`grep "boundary=" stream.org | cut -d'"' -f 2`

# cut the file into parts
# stream.part - header before the boundary
# stream.part1 - header after the bounday
# stream.part2 - body of the message
# stream.part3 - attachment in base64 (WAV file)
# stream.part4 - footer of the message
awk '/'$BOUNDARY'/{i++}{print > "stream.part"i}' stream.org

# if mail is having no audio attachment (plain text)
PLAINTEXT=`cat stream.part1 | grep 'plain'`
if [ "$PLAINTEXT" != "" ]
then

  # prepare to send the original stream
  cat stream.org > stream.new

# else, if mail is having audio attachment
else

  # cut the attachment into parts
  # stream.part3.head - header of attachment
  # stream.part3.wav.base64 - wav file of attachment (encoded base64)
  sed '7,$d' stream.part3 > stream.part3.wav.head
  sed '1,6d' stream.part3 > stream.part3.wav.base64

  # convert the base64 file to a wav file
  dos2unix -o stream.part3.wav.base64
  base64 -di stream.part3.wav.base64 > stream.part3.wav

  # convert wav file to mp3 file
  # -b 24 is using CBR, giving better compatibility on smartphones (you can use -b 32 to increase quality)
  # -V 2 is using VBR, a good compromise between quality and size for voice audio files
  lame -m m -b 24 stream.part3.wav stream.part3.mp3

  # convert back mp3 to base64 file
  base64 stream.part3.mp3 > stream.part3.mp3.base64

  # generate the new mp3 attachment header
  # change Type: audio/x-wav to Type: audio/mpeg
  # change name="msg----.wav" to name="msg----.mp3"
  sed 's/x-wav/mpeg/g' stream.part3.wav.head | sed 's/.wav/.mp3/g' > stream.part3.mp3.head

  # generate first part of mail body, converting it to LF only
  mv stream.part stream.new
  cat stream.part1 >> stream.new
  cat stream.part2 >> stream.new
  cat stream.part3.mp3.head >> stream.new
  dos2unix -o stream.new

  # append base64 mp3 to mail body, keeping CRLF
  unix2dos -o stream.part3.mp3.base64
  cat stream.part3.mp3.base64 >> stream.new

  # append end of mail body, converting it to LF only
  echo "" >> stream.tmp
  echo "" >> stream.tmp
  cat stream.part4 >> stream.tmp
  dos2unix -o stream.tmp
  cat stream.tmp >> stream.new

fi

# send the mail thru sendmail
cat stream.new | sendmail -t

# go back to original directory
popd

# remove all temporary files and temporary directory
rm -Rf $TMPDIR
 
Be sure to make it executable.
If you are using some other distributions than debian or ubuntu or some self  compiled packages, you may have to specify the full path for the executable files (/usr/local/bin/lame for example).

4. Voicemail configuration

On the Asterisk server side, we just need to configure the voicemail extension to use or script to send the mails.
This is done thru the voicemail.conf file, where :
  • In the [general] section, you need to setup some email specific parameters
  • In the [default] section (I suppose you use the default context for your voicemail), you need to setup the email address to use for each voicemail box.
So, finally your voicemail.conf configuration file should include these parameters :

/etc/asterisk/voicemail.conf
[general]
; Formats for writing voicemail. WAV is the best quality.
format=wav
; Who the e-mail notification should appear to come from
serveremail=yourpabxname@your.domain.com
; the email should contain the voicemail as an attachment
attach=yes
; You override the default program to send e-mail to use the script
mailcmd=/usr/sbin/sendmailmp3

[default]
; here you declare your voicemail, the email address which will receive the email & the automatic deletion of the message after mail is sent
yourvoicemailid => , yourname , your.email@address.com, , delete=yes

Once the file is saved, you just need to restart Asterisk for the configuration to be operational.

/etc/init.d/asterisk restart
That's it !
From now on, your Asterisk server is sendind all the voicemails by email using mp3 attachments.
Hope it helps.

Monday, 1 June 2015

Asterisk with CallerID setup

[100]
type=friend
host=dynamic
context=test
secret=1234
allow=all
callerid="Docomo" <8019613712>


Asterisk Friend Configuration behind the NAT

My asterisk Friend behind the NAT Configuration :

[Venkatesh]
type=friend
host=dynamic
secret=mysupersecret
context=mycontext
nat=force_rport,comedia
qualify=yes
disallow=all
allow=speex
allow=ulaw

Wednesday, 20 May 2015

Heartbeat Cluster Configuration

Node1 :
IpAddress(eth0):10.77.225.21
Subnetmask(eth0):255.0.0.0
Default Gateway(eth0):10.0.0.1
IpAddress(eth1):192.168.0.1(To send heartbeat signals to other nodes)
Sub net mask (eth1):255.255.255.0
Default Gateway (eth1):None(don’t specify any thing, leave blank for this interface default gateway).

Node2 :
IpAddress(eth0):10.77.225.22
Subnetmask(eth0):255.0.0.0
Default Gateway (eth0):10.0.0.1
IpAddress(eth1):192.168.0.2(To send heartbeat signals to other nodes)
Sub net mask (eth1):255.255.255.0
Default Gateway(eth1):None(don’t specify any thing, leave blank for this interface default gateway).


tyle=”font-family: verdana;”>4. Floating Ip address:10.77.225.20

Lets start configuration of Heartbeat cluster. And make a note that ever step in this Heartbeat cluster configuration is divided in two parts parts
1.(configurations on node1)
2.(configurations on node2)

For better understanding purpose

Step1 : Install the following packages in the same order which is shown

Step1(a) : Install the following packages on node1
#rpm -ivh heartbeat-2.1.2-2.i386.rpm
#rpm -ivh heartbeat-ldirectord-2.1.2-2.i386.rpm
#rpm -ivh heartbeat-pils-2.1.2-2.i386.rpm
#rpm -ivh heartbeat-stonith-2.1.2-2.i386.rpm

Step1(b) : Install the following packages on node2
#rpm -ivh heartbeat-2.1.2-2.i386.rpm
#rpm -ivh heartbeat-ldirectord-2.1.2-2.i386.rpm
#rpm -ivh heartbeat-pils-2.1.2-2.i386.rpm
#rpm -ivh heartbeat-stonith-2.1.2-2.i386.rpm


Step2 : By default the main configuration files (ha.cf, haresources and authkeys) are not present in /etc/ha.d/ folder we have to copy these three files from /usr/share/doc/heartbeat-2.1.2 to /etc/ha.d/

Step2(a) : Copy main configuration files from /usr/share/doc/heartbeat-2.1.2 to /etc/ha.d/ on node 1
#cp /usr/share/doc/heartbeat-2.1.2/ha.cf /etc/ha.d/
#cp /usr/share/doc/heartbeat-2.1.2/haresources /etc/ha.d/
#cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/

Step2(b) : Copy main configuration files from /usr/share/doc/heartbeat-2.1.2 to /etc/ha.d/ on node 2
#cp /usr/share/doc/heartbeat-2.1.2/ha.cf /etc/ha.d/
#cp /usr/share/doc/heartbeat-2.1.2/haresources /etc/ha.d/
#cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/


Step3 : Edit ha.cf file
#vi /etc/ha.d/ha.cf

Step3(a) : Edit ha.cf file as follows on node1
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 25
warntime 10
initdead 50
udpport 694
bcast eth1
ucast eth1 192.168.0.1
auto_failback on
node rp1.linuxnix.com
node rp2.linuxnix.com

Step3(b) : Edit ha.cf file as follows on node2
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 25
warntime 10
initdead 50
udpport 694
bcast eth1
ucast eth1 192.168.0.2
auto_failback on
node rp1.linuxnix.com
node rp2.linuxnix.com

Let me explain each entry in detail:
Debugfile : This is the file where debug info with good details for your heartbeat cluster will be stored, which is very much useful to do any kind of troubleshooting.

Logfile : This is the file where general logging of heartbeat cluster takes place.

Logfacility : This directive is used to specify where to log your heartbeat logs(if its local that indicates store logs locally or if it’s a syslog then store it on remote server and none to disable logging). And there are so many other options, please explore yourself.

Keepalive : This directive is used to set the time interval between heartbeat packets and the nodes to check the availability of other nodes. In this example I specified it as two seconds(keepalive 2).

Deadtime : A node is said to be dead if the other node didn’t receive any update form it.

Warntime : Time in seconds before issuing a “late heartbeat” warning in the logs.

Initdead : With some configurations, the network takes some time to start working after a reboot. This is a separate “deadtime” to handle that case. It should be at least twice the normal deadtime.

Udpport : This is the port used by heartbeat to send heartbeat packet/signals to other nodes to check availability(here in this example I used default port:694).

Bcast : Used to specify on which device/interface to broadcast the heartbeat packets.

Ucast : Used to specify on which device/interface to unicast the heartbeat packets.

auto_failback : This option determines whether a resource will automatically fail back to its “primary” node, or remain on whatever node is serving it until that node fails, or an administrator intervenes. In my example I have given as on that indicate if the failed node come back online, controle will be given to this node automatically. Let me put it in this way. I have two nodes node1 and node2. My node one machine is a high end one and node is for serving temporary purpose when node 1 goes down. Suppose node1 goes down, node2 will take the control and serve the service, and it will check periodically for node1 starts once it find that node 1 is up, the control is given to node1.

Node : This is used to specify the participated nodes in the cluster. In my cluster only two nodes are participating (rp1 and rp2) so just specify that entries. If in your implementation more nodes are participating please specify a
ll the nodes.


Step4 : Edit haresources file
#vi /etc/ha.d/haresources

Step4(a) : Just specify below entry in last line of this file on node1
rp1.linuxnix.com 10.77.225.20 squid

Step4(b) : Just specify below entry in last line of this file on node1
rp1.linuxnix.com 10.77.225.20 squid

Explanation of each entry :
rp1.linuxnix.com is the main node in the cluster
10.77.225.20 is the floating ip address of this cluster.

Squid : This is the service offered by the cluster. And make a note that this is the script file located in /etc/ha.d/ resource.d/.

Note : By default squid script file will not be there in that folder, I created it according to my squid configuration.

What actually this script file contains?
Ans : This is just a start/stop/restart script for the particular service. So that heartbeat cluster will take care of the starting/stoping/restarting of the service(here its squid).
Here is what squid script file contains.
http://sites.google.com/site/surendr...directs=0&d;=1

Step5 : Edit authkeys file, he authkeys configuration file contains information for Heartbeat to use when authenticating cluster members. It cannot be readable or writeable by anyone other than root. so change the permissions of the file to 600 on both the nodes..

Two lines are required in the authkeys file:
A line which says which key to use in signing outgoing packets.
One or more lines defining how incoming packets might be being signed.

Step5 (a) : Edit authkeys file on node1
#vi /etc/ha.d/authkeys
auth 2
#1 crc
2 sha1 HI!
#3 md5 Hello!
Now save and exit the file

Step5 (b) : Edit authkeys file on node2
#vi /etc/ha.d/authkeys
auth 2
#1 crc
2 sha1 HI!
#3 md5 Hello!
Now save and exit the file


Step6 : Edit /etc/hosts file to give entries of hostnames for the nodes


Step6(a) : Edit /etc/hosts file on node1 as below



10.77.225.21 rp1.linuxnix.com rp1
10.77.225.22 rp2.linuxnix.com rp2


Step6(b) : Edit /etc/hosts file on node2 as below



10.77.225.21 rp1.linuxnix.com rp1
10.77.225.22 rp2.linuxnix.com rp2

Step7 : Start Heartbeat cluster

Step7(a) : Start heartbeat cluster on node1
#service heartbeat start

Step7(b) : Start heartbeat cluster on node2
#service heartbeat start

Checking your Heartbeat cluster:
If your heartbeat cluster is running fine a Virtual Ethernet Interface is created on node1 and 10.77.225.20
Clipped output of my first node
# ifconfig

Eth0 Link encap:Ethernet HWaddr 00:02:A5:4C:AF:8E
inet addr:10.77.225.21 Bcast:10.77.231.255 Mask:255.255.248.0
inet6 addr: fe80::202:a5ff:fe4c:af8e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5714248 errors:0 dropped:0 overruns:0 frame:0
TX packets:19796 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1533278899 (1.4 GiB) TX bytes:4275200 (4.0 MiB)
Base address:0×5000 Memory:f7fe0000-f8000000

Eth0:0 Link encap:Ethernet HWaddr 00:02:A5:4C:AF:8E
inet addr:10.77.225.20 Bcast:10.77.231.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0×5000 Memory:f7fe0000-f8000000

Eth1 Link encap:Ethernet HWaddr 00:02:A5:4C:AF:8F
inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::202:a5ff:fe4c:af8f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:145979 errors:0 dropped:0 overruns:0 frame:0
TX packets:103753 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:38966724 (37.1 MiB) TX bytes:27640765 (26.3 MiB)
Base address:0×5040 Memory:f7f60000-f7f80000

Tuesday, 24 March 2015

How to do a screen share wiht Linux Terminal Bash using Screen

How to do a screen share wiht Linux Terminal Bash using Screen :

1) Create a screen
 screen
2) list the all available screens using below command
 screen -list
3) Now you can see all available screens, use the desired screen name on other client
 screen -x <name>

Here is the one example :


# screen
# screen -list
There is a screen on:
        9025.pts-4.Ubuntu-Server        (Tuesday 24 March 2015 06:57:53  IST)  (Attached)

use the 9025.pts-4.Ubuntu-Server name on other server like this

# screen -x 9025.pts-4.Ubuntu-Server

That's it.

Friday, 27 February 2015

Installing TeamViewer on ubuntu 14.04/12.04

To install Teamviewer in ubuntu 14.04 just follow the run below commands

sudo dpkg --add-architecture i386 sudo apt-get update wget http://www.teamviewer.com/download/teamviewer_linux.deb sudo dpkg -i teamviewer_linux.deb sudo apt-get install -f

Thursday, 19 February 2015

Converting Voice to Digital Form

Let's start with the beginning. VoIP sends digitized voice across computer networks. So how do we convert voice to the digital form?
When converting an analog signal (be it speech or another noise), you need to consider two important factors: sampling and quantization. Together, they determine the quality of the digitized sound.
  • Sampling is about the sampling rate — i.e. how many samples per second you use to encode the sound.
  • Quantization is about how many bits you use to represent each sample. The number of bits determines the number of different values you can represent with each sample.
Figures 1 and 2 show the idea of sampling — Figure 1 is the original analog signal, while Figure 2 shows the digitized form as a sequence of discrete samples.
Figure 1: Analog signal
Figure

Figure 2: Digitized signal
Figure

Quantization

As mentioned above, quantization is about how many bits you use to represent individual sound samples. In practice, we want to work with whole bytes, so let's consider 8 or 16 bits.
With 8-bit samples, each sample can represent 256 different values, so we can work with whole numbers between -128 and +127. Because of the whole numbers, it is inevitable that we introduce some noise into the signal as we convert it to digital samples. For example, if the exact analog value is "7.44125", we will represent it as "7". As we do this with each sample in the sequence, we slightly distort the signal — inject noise, in other words.
It turns out 8-bit samples do not result in a good quality. With only 256 sample values, the analog-to-digital conversion adds too much noise. The situation improves a lot if we switch to 16-bit samples as 16 bits give us 65536 different representations (from -32768 to +32767). 16-bit samples are what you will find on a CD and what VoIP codecs use as their input.

Sampling

Now that we have decided what sample size to use (16 bits), let's look at sampling rates. The table below shows three frequently used sampling rates:
TypeTransmitted BandwidthSampling Frequency
Telephone Speech300-3400 Hz8 kHz
Wide Band Speech50-7000 Hz16 kHz
CD quality audio20-20000 Hz44.1 kHz

With VoIP, you will most frequently encounter the sampling rate of 8 kilohertz. The frequency of 16 kHz can be used now and then in situations when a higher quality audio is required (with proportionally higher Internet bandwidth consumption).
The choice of sampling frequencies for the individual types of audio is not random. There is a rule (based on the work of Nyquist and Shanon) that the sampling frequency needs to be equal or greater than two times the transmitted bandwidth. Figures 3 and 4 show why this is required.
Figure 3
Figure
In Figure 3, the sinusoid represents the original analog sound. The large black dots are where we read our samples. Note that we take two samples in each period, i.e. the sampling rate is two times the frequency of the sound. This is the absolute minimum that will allow us to reconstruct a signal that is still comprehensible. It certainly won't be a hi-fi sound but it will have the correct frequency - see the thin black lines in the picture.
Figure 4
Figure
The Figure 4 shows a situation where we take less than two samples per period. The thin black lines show what would happen after we feed the samples into a digital-to-analog converter — we would hear something different from the original, a sound with lower frequency. This problem is known as "aliasing" since the lower frequency appears to be an "alias" to the original correct one.

Summary

In this piece, we discussed a conversion of voice to a digital format. We considered the influence of sampling frequency and of the sample's size. It's good to remember that VoIP most frequently works with the sampling frequency of 8 kilohertz and each sample is stored in 16 bits.

Friday, 13 February 2015

Asterisk OPUS SDP tewak

Step by step :
1) Get the asterisk code (I am using svn checkout)
2) Get the opus libraries, compile and install (See opus homepage)
3) Get the asterisk-opus patch: git://github.com/meetecho/asterisk-opus.git
4) Patch asterisk according to the documentation in asterisk-opus
5) Run bootstrap.sh in the asterisk src-directory
6) Now edit <asterisk-src>/chan/chan_sip.c
Look for the following code and fix it like shown below: (remove the "/2") that's it!
/* Opus, pass parameters we care about (FIXME could this be 'fb' and not 'wb'?) */
        case AST_FORMAT_OPUS:
                ast_str_append(a_buf, 0, "a=maxptime:%d\r\n", 60);      /* FIXME */
7) do ./configure, make menuconfig, make, make install
8) edit your sip.conf to enable opus (according to the asterisk-opus do...)
Please let me know if that helped, thanks.

Tuesday, 10 February 2015

Install Clementine on ubuntu 14.04/12.04/13.04 system | Install Clementine music player using apt


Install Clementine:

You can add the Clementine PPA and receive updates by running the command below in a terminal window (Press Ctrl+Alt+T to open the terminal):
sudo apt-add-repository ppa:me-davidsansome/clementine
So far, the PPA supports Ubuntu 14.04, Ubuntu 13.10, Ubuntu 12.10, and Ubuntu 12.04.

After added the PPA, install the player via the commands below or check for updates via System Updater:

sudo apt-get update 
sudo apt-get install clementine

Ubuntu Music player gstreamer0.10-plugins-ugly and gstreamer0.10-plugins-bad problem | Rhythmbox not able import the Audio files


Rythmbox Codec Isuue :
sudo apt-get remove --purge gstreamer0.10-plugins-ugly
sudo apt-get install gstreamer1.0-plugins-ugly

Friday, 6 February 2015

enabling full debug for the specific function.. Here i am enabling full debugging for the m_store() function.

enabling full debug for the specific function.. Here i am enabling full debugging for the m_store() function.

Also , you could enable full debug for the m_dump() function:
    set_debug(4);
    m_dump();
    set_debug();

Thursday, 22 January 2015

RTP Proxy Installation From Source



Basic Steps in RTP Proxy Installation:
This is a rookie guide for people running Ubuntu 9.04, have OpenSIPS 1.5.2 installed on their server, and wanted to implement RTPProxy as media server.

If your already have basic knowledge you can skip the basic steps and proceed to expert installation steps…

Objectives:
1. Package/Dependencies Installation
2. RTPProxy Installation
3. OpenSIPS 1.5.2 Configuration
4. Database MySQL 5.0.51a Configuration

Assumptions:
- OpenSIPS 1.5.2 (latest version) Installed.
– UDP/Media ports* are open on your router.
(Configure Router for the Ports to be used by rtpproxy by opening them first.)

Use dpkg command to list installed software and follow the codes listed bellow:

$ dpkg –get-selections
$ mkdir /backup
$ dpkg –get-selections > /backup/installed-software.log
$ cd /usr/src
$ wget http://b2bua.org/chrome/site/rtpproxy-1.2.0.tar.gz
$ tar -xzvf rtpproxy-1.2.0.tar.gz

Change to the directory and install the program
$ cd rtpproxy-1.2
$ ./configure
$ make
$ make install

Create a system user with no privileges and start the daemon running
$ adduser rtpproxy
$ rtpproxy -u rtpproxy

Now rtpproxy should be running and if you check in /var/run you should see rtpproxy.sockand rtpproxy.pid

Running Manually:
$ rtpproxy -l 192.168.1.109 -s udp:127.0.0.1:50000 -u usrname &
OR
$ rtpproxy -s udp:127.0.0.1:50000 -f -u opensips -l 192.168.1.109 &

Consideration:
Creating the user rtpproxy was not essential, you can run the daemon under whatever user you are logged in as by simply typing rtpproxy at the command but I read that it is safe practice to run the daemon under a non privileged user. (Maybe someone can comment on the linux user I added. I am not 100% on the security of the user added with no password but the way I understand it the user cannot access the system until a password is created.)

How do I get a list of packages not installed as dependencies?

aptitude search '~i !~M' -F '%p' --disable-columns | sort -u > currentlyinstalled.txt

Sunday, 11 January 2015

Install RabbitVCS svn Client in Ubunutu 12.04/12.10/13.04/13.10/14.04/14.10


Run the Terminal and go to the root with command: sudo su
We have to add the PPA or source list repository with the following command:

add-apt-repository ppa:rabbitvcs/ppa
Update your software package repositories with:

apt-get update
Then install RabbitVCS and support software package with the following commands:
apt-get install rabbitvcs-nautilus3
apt-get install rabbitvcs-gedit
apt-get install rabbitvcs-cli
apt-get install thunar-vcs-plugin

We must to install package rabbitvcs-thunar, but it package need thunarx-python version 0.3.0-1. Default software package thunarx-python in version 0.2.0, so we must to setup thunarx-python 0.3.0. How to install thunarx-python 0.3.0-1 in Ubuntu 12.04 LTS?

First step add the PPA to enable repository

add-apt-repository ppa:nilarimogard/webupd8
Update software package repositories:

apt-get update
Then install package thunarx-python
apt-get install thunarx-python
After install package thunarx-python 0.3.0-1, next install rabbitvcs-thunar with:
apt-get install rabbitvcs-thunar
After installation is complete, logout and log back in for changes to take effect.

E-mail Newsletter

Sign up now to receive breaking news and to hear what's new with us.

Recent Articles

© 2014 VOIP4Learn. WP themonic converted by Bloggertheme9. Powered by Blogger.
TOP