spandsp 0.0.6
|
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 * $Id: g1050.h,v 1.12 2009/06/01 16:27:12 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. 168 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 /*! Maximum jitter in the segment. */ 00097 double max_jitter; 00098 } g1050_segment_model_t; 00099 00100 /*! The model definition for the core network (backbone) segment */ 00101 typedef struct 00102 { 00103 /*! Basic delay of the backbone for regional paths */ 00104 double base_regional_delay; 00105 /*! Basic delay of the backbone for intercontinental paths */ 00106 double base_intercontinental_delay; 00107 /*! Percentage packet loss of the backbone */ 00108 /*! Percentage packet loss of the backbone. */ 00109 double percentage_packet_loss; 00110 /*! Maximum jitter in the backbone. */ 00111 double max_jitter; 00112 /*! Interval between the backbone route flapping between two paths, in seconds. */ 00113 double route_flap_interval; 00114 /*! The difference in backbone delay between the two routes we flap between, in seconds. */ 00115 double route_flap_delay; 00116 /*! The interval between link failures. */ 00117 double link_failure_interval; 00118 /*! The duration of link failures. */ 00119 double link_failure_duration; 00120 /*! Probability of packet loss in the backbone. */ 00121 double prob_packet_loss; 00122 /*! Probability of a packet going out of sequence in the backbone. */ 00123 double prob_oos; 00124 } g1050_core_model_t; 00125 00126 /*! The model definition for a complete end-to-end path */ 00127 typedef struct 00128 { 00129 /*! The likelyhood of occurance probabilities for the A, B and C scenarios defined in G.1050 */ 00130 int loo[3]; 00131 g1050_segment_model_t sidea_lan; 00132 g1050_segment_model_t sidea_access_link; 00133 g1050_core_model_t core; 00134 g1050_segment_model_t sideb_access_link; 00135 g1050_segment_model_t sideb_lan; 00136 } g1050_model_t; 00137 00138 /*! The speed model for a complete end-to-end path */ 00139 typedef struct 00140 { 00141 int sidea_lan_bit_rate; 00142 int sidea_lan_multiple_access; 00143 int sidea_access_link_bit_rate_ab; 00144 int sidea_access_link_bit_rate_ba; 00145 int sidea_access_link_qos_enabled; 00146 int sideb_lan_bit_rate; 00147 int sideb_lan_multiple_access; 00148 int sideb_access_link_bit_rate_ab; 00149 int sideb_access_link_bit_rate_ba; 00150 int sideb_access_link_qos_enabled; 00151 double loo; 00152 } g1050_channel_speeds_t; 00153 00154 /*! The model state for a LAN or access link segment */ 00155 typedef struct 00156 { 00157 /*! The type of link, G1050_LAN_LINK or G_1050_ACCESS_LINK */ 00158 int link_type; 00159 /*! 1 if in the high loss state, or 0 if in the low loss state. */ 00160 int high_loss; 00161 00162 /*! The probability of a loss rate change, for both loss rate states. */ 00163 double prob_loss_rate_change[2]; 00164 /*! The probability of a impulse occuring, for both loss rate states. */ 00165 double prob_impulse[2]; 00166 00167 /*! The maximum permitted height of impulses. */ 00168 double impulse_height; 00169 /*! The impulse decay coefficient. */ 00170 double impulse_coeff; 00171 00172 /*! The basic serial delay due to the link. */ 00173 double serial_delay; 00174 /*! Peak jitter in the segment. */ 00175 double max_jitter; 00176 /*! The probability of packet loss. */ 00177 double prob_packet_loss; 00178 /*! The probability of packet loss due to collision. */ 00179 double prob_packet_collision_loss; 00180 /*! The maximum addition delay due to congestion. */ 00181 double congestion_delay; 00182 00183 /*! TRUE if QoS is enabled on the link. */ 00184 int qos_enabled; 00185 /*! TRUE if the link is a multiple access type (e.g. an ethernet hub). */ 00186 int multiple_access; 00187 00188 /*! The latest packet arrival time seen on the link. */ 00189 double last_arrival_time; 00190 00191 /*! 3 seconds of predicted delays for the link */ 00192 double delays[3*G1050_TICKS_PER_SEC]; 00193 00194 /*! A count of packets lost on the link. */ 00195 uint32_t lost_packets; 00196 /*! An extra debug count of packets lost on the link. */ 00197 uint32_t lost_packets_2; 00198 } g1050_segment_state_t; 00199 00200 /*! The model state for the core network (backbone) segment */ 00201 typedef struct 00202 { 00203 /* Router model. */ 00204 int32_t route_flap_counter; 00205 int32_t route_flap_interval; 00206 double route_flap_delta; 00207 00208 /* Link failure model. */ 00209 int32_t link_failure_counter; 00210 int32_t link_recovery_counter; 00211 00212 int32_t link_failure_interval_ticks; 00213 int32_t link_failure_duration_ticks; 00214 00215 /*! Basic backbone delay */ 00216 double base_delay; 00217 /*! Peak jitter in the backbone delay */ 00218 double max_jitter; 00219 /*! Probability of packet loss in the backbone, in percent */ 00220 double prob_packet_loss; 00221 /*! Probability of a packet going out of sequence in the backbone. */ 00222 double prob_oos; 00223 00224 /*! The latest packet arrival time seen on the link. */ 00225 double last_arrival_time; 00226 double delay_delta; 00227 00228 /*! 3 seconds of predicted delays for the link */ 00229 double delays[3*G1050_TICKS_PER_SEC]; 00230 00231 /*! A count of packets lost on the link. */ 00232 uint32_t lost_packets; 00233 /*! An extra debug count of packets lost on the link. */ 00234 uint32_t lost_packets_2; 00235 } g1050_core_state_t; 00236 00237 /*! The definition of an element in the packet queue */ 00238 typedef struct g1050_queue_element_s 00239 { 00240 struct g1050_queue_element_s *next; 00241 struct g1050_queue_element_s *prev; 00242 int seq_no; 00243 double departure_time; 00244 double arrival_time; 00245 int len; 00246 uint8_t pkt[]; 00247 } g1050_queue_element_t; 00248 00249 /*! The model definition for a complete end-to-end path */ 00250 typedef struct 00251 { 00252 int packet_rate; 00253 int packet_size; 00254 float base_time; 00255 g1050_segment_state_t segment[4]; 00256 g1050_core_state_t core; 00257 double arrival_times_1[3*G1050_TICKS_PER_SEC]; 00258 double arrival_times_2[3*G1050_TICKS_PER_SEC]; 00259 g1050_queue_element_t *first; 00260 g1050_queue_element_t *last; 00261 } g1050_state_t; 00262 00263 extern g1050_constants_t g1050_constants[1]; 00264 extern g1050_channel_speeds_t g1050_speed_patterns[168]; 00265 extern g1050_model_t g1050_standard_models[9]; 00266 00267 #ifdef __cplusplus 00268 extern "C" 00269 { 00270 #endif 00271 00272 SPAN_DECLARE(g1050_state_t *) g1050_init(int model, 00273 int speed_pattern, 00274 int packet_size, 00275 int packet_rate); 00276 00277 SPAN_DECLARE(void) g1050_dump_parms(int model, int speed_pattern); 00278 00279 SPAN_DECLARE(int) g1050_put(g1050_state_t *s, 00280 const uint8_t buf[], 00281 int len, 00282 int seq_no, 00283 double departure_time); 00284 00285 SPAN_DECLARE(int) g1050_get(g1050_state_t *s, 00286 uint8_t buf[], 00287 int max_len, 00288 double current_time, 00289 int *seq_no, 00290 double *departure_time, 00291 double *arrival_time); 00292 00293 SPAN_DECLARE(void) g1050_queue_dump(g1050_state_t *s); 00294 00295 #ifdef __cplusplus 00296 } 00297 #endif 00298 00299 #endif 00300 /*- End of file ------------------------------------------------------------*/