Friday, April 14, 2017

Packet Loss, Reordering, Jitter simple image explanation

In the below case packet #2 is lost




In the case below, #2 is out of order received




In thie case each packet is sent in 20 ms interval. But received in different intervals. #1 received almost in 20 ms, #2,#2,#4 received altogether 60 ms later. #5 was almost reaching within 20ms.


references:
https://webrtcglossary.com/jitter-buffer/

VoIP bandwidth consumption of various codecs

VoIP Bandwidth consumption naturally depends on the codec used.
When calculating bandwidth, one can't assume that every channel is used all the time. Normal conversation includes a lot of silence, which often means no packets are sent at all. So even if one voice call sets up two 64 Kbit RTP streams over UDP over IP over Ethernet (which adds overhead), the full bandwidth is not used at all times.

A codec that sends a 64kb stream results in a much larger IP network stream. The main cause of the extra bandwidth usage is IP and UDP headers. VoIP sends small packets and so, many times, the headers are actually much larger than the data part of the packet.

The bandwidth used depends also on the datalink (layer2) protocols. Several things influence the bandwidth used, payload size, ATM cell headers, VPN headers, use of header compression etc.

Teracall has the table which shows how the codec's theoretical bandwidth usage expands with UDP/IP headers:

Codec BR NEB
G.711 64 Kbps 87.2 Kbps
G.729 8 Kbps 31.2 Kbps
G.723.1 6.4 Kbps 21.9 Kbps
G.723.1 5.3 Kbps 20.8 Kbps
G.726 32 Kbps 55.2 Kbps
G.726 24 Kbps 47.2 Kbps
G.728 16 Kbps 31.5 Kbps
iLBC 15 Kbps 27.7 Kbps

Constructor initialization order

Class C {
   int a;
   int b;
   C():b(1),a(2){} //warning, should be C():a(2),b(1)
}

In this case the order should be a(2), b(1) because the order in which declared in the class is the same
or we can turn on -Wno-reorder

references
http://stackoverflow.com/questions/1564937/gcc-warning-will-be-initialized-after

A good explanation of VoIP packet size

The best explanation is in chapter 5 of the Authorized Self-Study Guide for Cisco Voice over IP (CVoice) Second Edition by Kevin Wallace.  Basically, the formula is Bytes_per_sample = Sample_Size * CODEC_Bandwidth / 8 plus overhead.
So, if your sample size is 20 ms (.02 seconds)  and you are using the G.711 CODEC, then your basic voice information requires
.02 * 64000 / 8 = 160 bytes per sample.  To that, you must add the overhead, which would be 20 bytes for the IP header,
8 bytes for the UDP header, and 12 bytes for the RTP header (to make sure your packets are in the correct order at the receiving end).
So, each voice packet will require 200 bytes.  Then, you need to add your Layer 2 overhead (at least 18 bytes for Ethernet).
So, each frame will require at least 218 bytes.  And you may also have trunk or tunneling overhead to consider.

Yes, voice packets are small, but you need a lot of them to carry voice.  That's why we use compression techniques.
cRTP compresses the IP/UDP/RTP header to either 2 or 4 bytes (4 if you implement check sum).  This significantly reduces the overhead.

In addition, you can use a CODEC that requires lower bandwidth.  The G.729 CODEC only requires 8000 bits per second, so if you used
G.729 and RTP header compression you would get
.02 * 8000 / 8 = 20 bytes of voice information plus 4 bytes for IP/UDP/RTP for an IP packet size of 24 bytes.  Then, you can add your
Layer 2 overhead, whatever it is.

references:
https://learningnetwork.cisco.com/thread/11162

Thursday, April 13, 2017

VoIP why multiple channels required ?

Any client assessment of VoIP should start with bandwidth capacity planning. This is particularly important because VoIP voice quality degrades quickly with contention from other applications. The goal is to gauge the total bandwidth on the client's network, estimate the current bandwidth utilization of applications, decide if there is enough remaining (unused) bandwidth to sustain the maximum number of planned voice channels (roughly 64 kbps per channel), and try to predict the amount of bandwidth needed by applications or users into the foreseeable future.

"Network capacity becomes more a measure of how many simultaneous calls the network can process," Zuk said. "This concept of peak load -- the maximum assumed volume that the network should be able to handle -- will be the basis of VoIP capacity planning." If you determine that your client's network has adequate bandwidth now and into the future, you can plan and implement VoIP. If there isn't enough available network bandwidth (or you suspect a near-term bandwidth shortage), you'll need to recommend suitable network upgrades for the client before VoIP can be deployed.

Essentially, each channel can only handle so much of data per channel 64Kbps

references:
http://searchitchannel.techtarget.com/feature/Channel-Explained-Voice-over-Internet-Protocol-VoIP

What are various AMR Encoder modes?

MR122 : 12.2Kb/s
MR102 : 10.2Kb/s
MR795 : 7.95Kb/s
MR74  : 7.4Kb/s 
MR67  : 6.7Kb/s 
MR59  : 5.9Kb/s 
MR515 : 5.15Kb/s 

MR475 : 4.75Kb/s 

references:
https://books.google.co.in/books?id=767W1gWhj_oC&pg=PT363&lpg=PT363&dq=what+is+mr122+in+amr+encoder&source=bl&ots=sZEUJbMCW9&sig=_xVA4FxKQuEakBsTes_ZnxnIx0A&hl=en&sa=X&ved=0ahUKEwiK2IiG9qDTAhUFqo8KHRh8AFEQ6AEILjAC#v=onepage&q=what%20is%20mr122%20in%20amr%20encoder&f=false

Tuesday, April 11, 2017

Mac - iOS Universal Clipboard

This is a cool feature, if someone want to copy content from Mac and paste it anywhere. For this, both devices should be signed in to same Apple ID and Wifi, Bluetooth should be turned on,

Sign into iCloud with the same Apple ID on all your devices.
Make sure Bluetooth is turned on on all your devices.
Make sure Wi-Fi is turned on on all your devices.
Make sure your devices are near each other. Universal Clipboard is proximity-dependent.
Copy your text, photo, or video on one device.
Paste your text, photo, or video on your other device.




references:
http://www.imore.com/how-use-universal-clipboard-macos-sierra