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

Generated on Tue Jul 24 11:29:28 2007 for libspandsp by  doxygen 1.5.2