IP Telephony Project By: Liane Lewin Shahar Eytan Guided By: Ran Cohen - IBM Vitali Sokhin - Technion Agenda • • • • • • • What is IP Telephony The Jitter Buffer The Jitter Buffer Algorithm Implementation The Code Simulations Conclusions Network Lab - Technion 2 Agenda • What is IP Telephony • • • • • • The Jitter Buffer The Jitter Buffer Algorithm Implementation The Code Simulations Conclusions Network Lab - Technion 3 What is IP Telephony? • IP stands for Internet Protocol • Basically, it enables passing of audio data over the Internet. • The data is passed by UDP packets. Network Lab - Technion 4 Why was that needed? • Imagine being able to call anywhere in the world for the cost of a local call… • Imagine being able to link your telephone system into your web page… • Imagine being able to give your customers a world wide toll-free number… • IP Telephony enables all that, and more... Network Lab - Technion 5 Sounds easy? Well, it’s not that easy! • We’re dealing with real time data, delays are critical – Remember the last time you talked to South America... • You would like a continuous conversation – You will not like to hear half words or sentences ( “ I ………….. you “ ) Network Lab - Technion 6 • Audio data is sent by UDP. • The network is not that reliable. – – – – – There are Routers on the way Datagrams are delayed Some times they change their order Some times they just vanish Some times they all come at once • Some one has to put an end to this mess... Network Lab - Technion 7 Agenda • What is IP Telephony • The Jitter Buffer • • • • • The Jitter Buffer Algorithm Implementation The Code Simulations Conclusions Network Lab - Technion 8 Jitter Buffer (JB) • Jitter - the speed variation between slowly and quickly traveling packets. • The JB stores packets, allowing most of the slower packets to catch up. • The less control in routing, the more jitter that results. Network Lab - Technion 9 The Jitter Buffer Catch: More jitter means longer JB Longer JB introduces more latency Shorter JB loses too many packets Lose of packets cause voice to tumble Network Lab - Technion 10 The Goal: How to control the Jitter Buffer? • Need to find a good algorithm that will control the JB. • A convenient Test Bench should be designed in order to simulate the algorithm. • The Test Bench will not be a full VoIP system (with gateways, routing, etc.) Network Lab - Technion 11 Our Solution: The Packet Source The Network Module JB Network Lab - Technion Destination Module 12 Agenda • What is IP Telephony • The Jitter Buffer • The Jitter Buffer Algorithm • • • • Implementation The Code Simulations Conclusions Network Lab - Technion 13 The JB Algorithm: The frames number in the JB adjusts according to the High Water Mark (HWM) • Whenever the JB is empty, wait till packets will fill it to the HWM. • Whenever the jitter changes, check if the change is less then the last jitters. Network Lab - Technion 14 • If the jitter is consistently shorter then reduce the HWM. • If the number of packets exceeds HWM X Const then throw the remains. • The HWM will increase whenever the Jitter exceeds a certain limit. • Remember, the goal is to have the shorter latency and the fewer breaks! Network Lab - Technion 15 The Algorithm Parameters: • Prefetch - Initialized at the beginning of the JB operation. It is constantly updated according to the network behavior. • Stable History - Initialized at the beginning of the JB operation. It defines the time limit (in JB operations) needed to decide that the network is relatively stable. Network Lab - Technion 16 The Algorithm Parameters (cont): • Prefetch reduction: Only when all the previous jitters during the last Stable History cycle where below the HWM. The Prefetch is reduced according to the difference between the current HWM and the maximal jitter. • Prefetch increment: Each time the jitter is higher then the Prefetch, it will increase to the jitter value. Network Lab - Technion 17 The Algorithm Parameters (cont): • Packets are thrown whenever their number is 50% higher then the HWM. • The algorithm parameters are updated at every mode switch. Note: The parameters values are subject to change according to the packet size. The only well defined parameter is the Stable History. Network Lab - Technion 18 Agenda • What is IP Telephony • The Jitter Buffer • The Jitter Buffer Algorithm • Implementation • The Code • Simulations • Conclusions Network Lab - Technion 19 Implementation Notes • The project consist of 2 main blocks – The Packet Source and the Network module • It’s all part of the Test Bench – The Destination module • This is the main module. Improvement of this module is the goal of the project. Network Lab - Technion 20 2 ways to implement the Network module: 1. Simulation: – The path between source and destination is divided by Routers. – Number of Routers could be modeled by one queue as well. – For this queue we will add working parameters that characterize a network • Frequency of the breaks in its operation • The duration of a break Network Lab - Technion 21 2. Using the ‘Real’ Net – We used a Mirror Application • It runs on a far computer • All it does is replying the sender by sending his packets back immediately – While traveling through the net, packets: • where delayed • changed order • vanished away Network Lab - Technion 22 The Destination: • Receives the voice packets • Uses the Jitter Buffer Algorithm • Tries to provide the user with smooth and short delayed voice Network Lab - Technion 23 Agenda • • • • What is IP Telephony The Jitter Buffer The Jitter Buffer Algorithm Implementation • The Code • Simulations • Conclusions Network Lab - Technion 24 The Code: • It contains 2 basic applications – The Network Simulator – The Destination • Each contains number of threads • Both NT and UNIX compatible • Few basic classes are being used to simplify the code (Sockets, Threads and Synchronization) Network Lab - Technion 25 Implementing the Jitter Buffer • It’s basically a cyclic array • Allocated in memory at the beginning of the operation • Its size is a multiple of the Frame Size Get Put Wrap around Network Lab - Technion 26 The JB Control • 3 Threads controls the JB I/O: 1. JB Input Thread: • Poles the network for incoming frames and inserts them to the JB according to their sequence number. 2. JB Output Thread: • Reads from the JB in constant frequency (equal to the sender’s), and plays the data to the user. 3. User Interaction Thread: • Gets the user commands Network Lab - Technion 27 The Network Simulator • The Network is modeled as queue (Cyclic Queue) • 3 threads control its operation (Input, Output and User Interaction) • The input/output of the frames is done in order - FIFO Network Lab - Technion 28 The Network Simulator (cont.) • The simulated network works according to the following parameters: – Breaks - Caused by heavy traffic in the net – Break frequency Those parameters could be entered by the user, or selected randomly Remember, if we want real data we still got the Mirror app. Network Lab - Technion 29 Agenda • • • • • What is IP Telephony The Jitter Buffer The Jitter Buffer Algorithm Implementation The Code • Simulations • Conclusions Network Lab - Technion 30 The Simulations Goal • Validate the code • Fix the constants values • Find the JB advantages over Simple algorithms Network Lab - Technion 31 In each simulation we checked: • At any time: – – – – – Number of packets in the buffer (Buffer) The number of input tries vs. output tries (Level) The jitter (Jitter) The HWM (Prefetch) The approximate packet delay (Delay) • For comparison we managed also a simple buffer Network Lab - Technion 32 Simulation Area: • Simulations ran on the “real net” using the Mirror application. It ran on computers in USA, Japan and closer. • To exercise the algorithm on different scenarios we used the network simulator. • For better view, we processed the data using Matlab. Network Lab - Technion 33 Simulation Output Example Network Lab - Technion 34 On the “Real” net with the Mirror Network Lab - Technion 35 Agenda • • • • • • What is IP Telephony The Jitter Buffer The Jitter Buffer Algorithm Implementation The Code Simulations • Conclusions Network Lab - Technion 36 Conclusions: • When coming to improve network connected applications, dynamic algorithms are needed. • Applying a JB to the destination improves the latency and breaks. • Its advantage is mainly when the net stabilizes. Not significant when it is static. Network Lab - Technion 37 Network Lab - Technion 38