g1050.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * g1050.h - IP network modeling, as per G.1050/TIA-921.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2007 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  */
00025 
00026 /*! \file */
00027 
00028 /*! \page g1050_ip_network_model_page G.1050/TIA-921 IP network path model
00029 \section g1050_ip_network_model_page_sec_1 What does it do?
00030 The ITU G.1050 specification defines a model of an IP network, appropriate
00031 for the testing of how streaming media woud behave across the internet. The
00032 model is based on a path having 5 segments:
00033  - a local LAN (wired or wireless)
00034  - an access link to the internet
00035  - an internet of arbitrary complexity
00036  - an access link from the internet
00037  - a distant LAN (wired or wireless)
00038 The impairments typical of these segments at various service levels are modelled.
00039 8 standard service level behaviours are defined, covering lightly loaded to heavily
00040 congested levels. 168 standard sets of link speeds are defined, covering typical
00041 wired and wireless LAN, broadband access link, and backbone characteristics.
00042 
00043 The G.1050 model is suitable for testing the behaviour of RTP, UDPTL and other streaming
00044 protocols for packet loss and jitter behaviour.
00045 */
00046 
00047 #if !defined(_G1050_H_)
00048 #define _G1050_H_
00049 
00050 /* This is the time slice at which delays, packet loss, etc. are calculated. */
00051 #define G1050_TICKS_PER_SEC         1000
00052 
00053 /* Search back 200 ms to preserve order of legitimately out of sequence packets. */
00054 #define SEARCHBACK_PERIOD           200
00055 
00056 #define G1050_LOW_LOSS      0
00057 #define G1050_HIGH_LOSS     1
00058 
00059 #define G1050_LAN_LINK      1
00060 #define G1050_ACCESS_LINK   2
00061 
00062 /*! Segment constants, as defined in G.1050. */
00063 typedef struct
00064 {
00065     /*! Probability of changing from low to high and high to low loss states */
00066     double prob_loss_rate_change[2];
00067     /*! Probability of an impulse in the low and high loss states */
00068     double prob_impulse[2][2];
00069 
00070     /*! Impulse height, based on MTU and bit rate */
00071     double impulse_height;
00072     /*! Impulse decay coefficient for the single pole IIR filter. */
00073     double impulse_coeff;
00074 
00075     /*! Probability of packet loss due to occupancy. */
00076     double prob_packet_loss;
00077     /*! Probability of packet loss due to a multiple access collision. */
00078     double prob_packet_collision_loss;
00079 } g1050_segment_constants_t;
00080 
00081 /*! End-to-end constants, as defined in G.1050. */
00082 typedef struct
00083 {
00084     g1050_segment_constants_t segment[4];
00085 } g1050_constants_t;
00086 
00087 /*! The model definition for a LAN or access link segment */
00088 typedef struct
00089 {
00090     /*! Percentage occupancy of the media */
00091     double percentage_occupancy;
00092     /*! MTU of the media */
00093     int mtu;
00094     /*! Maximum jitter in the segment. */
00095     double max_jitter;
00096 } g1050_segment_model_t;
00097 
00098 /*! The model definition for the core network (backbone) segment */
00099 typedef struct
00100 {
00101     /*! Basic delay of the backbone for regional paths */
00102     double base_regional_delay;
00103     /*! Basic delay of the backbone for intercontinental paths */
00104     double base_intercontinental_delay;
00105     /*! Percentage packet loss of the backbone */
00106     /*! Percentage packet loss of the backbone. */
00107     double percentage_packet_loss;
00108     /*! Maximum jitter in the backbone. */
00109     double max_jitter;
00110     /*! Interval between the backbone route flapping between two paths, in seconds. */
00111     double route_flap_interval;
00112     /*! The difference in backbone delay between the two routes we flap between, in seconds. */
00113     double route_flap_delay;
00114     /*! The interval between link failures. */
00115     double link_failure_interval;
00116     /*! The duration of link failures. */
00117     double link_failure_duration;
00118     /*! Probability of packet loss in the backbone. */
00119     double prob_packet_loss;
00120     /*! Probability of a packet going out of sequence in the backbone. */
00121     double prob_oos;
00122 } g1050_core_model_t;
00123 
00124 /*! The model definition for a complete end-to-end path */
00125 typedef struct
00126 {
00127     /*! The likelyhood of occurance probabilities for the A, B and C scenarios defined in G.1050 */
00128     int loo[3];
00129     g1050_segment_model_t sidea_lan;
00130     g1050_segment_model_t sidea_access_link;
00131     g1050_core_model_t core;
00132     g1050_segment_model_t sideb_access_link;
00133     g1050_segment_model_t sideb_lan;
00134 } g1050_model_t;
00135 
00136 /*! The speed model for a complete end-to-end path */
00137 typedef struct
00138 {
00139     int sidea_lan_bit_rate;
00140     int sidea_lan_multiple_access;
00141     int sidea_access_link_bit_rate_ab;
00142     int sidea_access_link_bit_rate_ba;
00143     int sidea_access_link_qos_enabled;
00144     int sideb_lan_bit_rate;
00145     int sideb_lan_multiple_access;
00146     int sideb_access_link_bit_rate_ab;
00147     int sideb_access_link_bit_rate_ba;
00148     int sideb_access_link_qos_enabled;
00149     double loo;
00150 } g1050_channel_speeds_t;
00151 
00152 /*! The model state for a LAN or access link segment */
00153 typedef struct
00154 {
00155     /*! The type of link, G1050_LAN_LINK or G_1050_ACCESS_LINK */
00156     int link_type;
00157     /*! 1 if in the high loss state, or 0 if in the low loss state. */
00158     int high_loss;
00159 
00160     /*! The probability of a loss rate change, for both loss rate states. */
00161     double prob_loss_rate_change[2];
00162     /*! The probability of a impulse occuring, for both loss rate states. */
00163     double prob_impulse[2];
00164 
00165     /*! The maximum permitted height of impulses. */
00166     double impulse_height;
00167     /*! The impulse decay coefficient. */
00168     double impulse_coeff;
00169 
00170     /*! The basic serial delay due to the link. */
00171     double serial_delay;
00172     /*! Peak jitter in the segment. */
00173     double max_jitter;
00174     /*! The probability of packet loss. */
00175     double prob_packet_loss;
00176     /*! The probability of packet loss due to collision. */
00177     double prob_packet_collision_loss;
00178     /*! The maximum addition delay due to congestion. */
00179     double congestion_delay;
00180 
00181     /*! TRUE if QoS is enabled on the link. */
00182     int qos_enabled;
00183     /*! TRUE if the link is a multiple access type (e.g. an ethernet hub). */
00184     int multiple_access;
00185 
00186     /*! The latest packet arrival time seen on the link. */
00187     double last_arrival_time;
00188 
00189     /*! 3 seconds of predicted delays for the link */
00190     double delays[3*G1050_TICKS_PER_SEC];
00191     
00192     /*! A count of packets lost on the link. */
00193     uint32_t lost_packets;
00194     /*! An extra debug count of packets lost on the link. */
00195     uint32_t lost_packets_2;
00196 } g1050_segment_state_t;
00197 
00198 /*! The model state for the core network (backbone) segment */
00199 typedef struct
00200 {
00201     /* Router model. */
00202     int32_t route_flap_counter;
00203     int32_t route_flap_interval;
00204     double route_flap_delta;
00205 
00206     /* Link failure model. */
00207     int32_t link_failure_counter;
00208     int32_t link_recovery_counter;
00209 
00210     int32_t link_failure_interval_ticks;
00211     int32_t link_failure_duration_ticks;
00212 
00213     /*! Basic backbone delay */
00214     double base_delay;
00215     /*! Peak jitter in the backbone delay */
00216     double max_jitter;
00217     /*! Probability of packet loss in the backbone, in percent */
00218     double prob_packet_loss;
00219     /*! Probability of a packet going out of sequence in the backbone. */
00220     double prob_oos;
00221 
00222     /*! The latest packet arrival time seen on the link. */
00223     double last_arrival_time;
00224     double delay_delta;
00225 
00226     /*! 3 seconds of predicted delays for the link */
00227     double delays[3*G1050_TICKS_PER_SEC];
00228 
00229     /*! A count of packets lost on the link. */
00230     uint32_t lost_packets;
00231     /*! An extra debug count of packets lost on the link. */
00232     uint32_t lost_packets_2;
00233 } g1050_core_state_t;
00234 
00235 /*! The definition of an element in the packet queue */
00236 typedef struct g1050_queue_element_s
00237 {
00238     struct g1050_queue_element_s *next;
00239     struct g1050_queue_element_s *prev;
00240     int seq_no;
00241     double departure_time;
00242     double arrival_time;
00243     int len;
00244     uint8_t pkt[];
00245 } g1050_queue_element_t;
00246 
00247 /*! The model definition for a complete end-to-end path */
00248 typedef struct
00249 {
00250     int packet_rate;
00251     int packet_size;
00252     float base_time;
00253     g1050_segment_state_t segment[4];
00254     g1050_core_state_t core;
00255     double arrival_times_1[3*G1050_TICKS_PER_SEC];
00256     double arrival_times_2[3*G1050_TICKS_PER_SEC];
00257     g1050_queue_element_t *first;
00258     g1050_queue_element_t *last;
00259 } g1050_state_t;
00260 
00261 extern g1050_constants_t g1050_constants[1];
00262 extern g1050_channel_speeds_t g1050_speed_patterns[168];
00263 extern g1050_model_t g1050_standard_models[9];
00264 
00265 #ifdef  __cplusplus
00266 extern "C"
00267 {
00268 #endif
00269 
00270 SPAN_DECLARE(g1050_state_t *) g1050_init(int model,
00271                                          int speed_pattern,
00272                                          int packet_size,
00273                                          int packet_rate);
00274 
00275 SPAN_DECLARE(void) g1050_dump_parms(int model, int speed_pattern);
00276 
00277 SPAN_DECLARE(int) g1050_put(g1050_state_t *s,
00278                             const uint8_t buf[],
00279                             int len,
00280                             int seq_no,
00281                             double departure_time);
00282 
00283 SPAN_DECLARE(int) g1050_get(g1050_state_t *s,
00284                             uint8_t buf[],
00285                             int max_len,
00286                             double current_time,
00287                             int *seq_no,
00288                             double *departure_time,
00289                             double *arrival_time);
00290 
00291 SPAN_DECLARE(void) g1050_queue_dump(g1050_state_t *s);
00292 
00293 #ifdef  __cplusplus
00294 }
00295 #endif
00296 
00297 #endif
00298 /*- End of file ------------------------------------------------------------*/

Generated on 25 Jan 2012 for spandsp by  doxygen 1.6.1