Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/spandsp-sim/spandsp/g1050.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * g1050.h - IP network modeling, as per G.1050/TIA-921. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2007 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: g1050.h,v 1.12 2009/06/01 16:27:12 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 /*! \page g1050_ip_network_model_page G.1050/TIA-921 IP network path model | |
| 31 \section g1050_ip_network_model_page_sec_1 What does it do? | |
| 32 The ITU G.1050 specification defines a model of an IP network, appropriate | |
| 33 for the testing of how streaming media woud behave across the internet. The | |
| 34 model is based on a path having 5 segments: | |
| 35 - a local LAN (wired or wireless) | |
| 36 - an access link to the internet | |
| 37 - an internet of arbitrary complexity | |
| 38 - an access link from the internet | |
| 39 - a distant LAN (wired or wireless) | |
| 40 The impairments typical of these segments at various service levels are modelled. | |
| 41 8 standard service level behaviours are defined, covering lightly loaded to heavily | |
| 42 congested levels. 168 standard sets of link speeds are defined, covering typical | |
| 43 wired and wireless LAN, broadband access link, and backbone characteristics. | |
| 44 | |
| 45 The G.1050 model is suitable for testing the behaviour of RTP, UDPTL and other streaming | |
| 46 protocols for packet loss and jitter behaviour. | |
| 47 */ | |
| 48 | |
| 49 #if !defined(_G1050_H_) | |
| 50 #define _G1050_H_ | |
| 51 | |
| 52 /* This is the time slice at which delays, packet loss, etc. are calculated. */ | |
| 53 #define G1050_TICKS_PER_SEC 1000 | |
| 54 | |
| 55 /* Search back 200 ms to preserve order of legitimately out of sequence packets. */ | |
| 56 #define SEARCHBACK_PERIOD 200 | |
| 57 | |
| 58 #define G1050_LOW_LOSS 0 | |
| 59 #define G1050_HIGH_LOSS 1 | |
| 60 | |
| 61 #define G1050_LAN_LINK 1 | |
| 62 #define G1050_ACCESS_LINK 2 | |
| 63 | |
| 64 /*! Segment constants, as defined in G.1050. */ | |
| 65 typedef struct | |
| 66 { | |
| 67 /*! Probability of changing from low to high and high to low loss states */ | |
| 68 double prob_loss_rate_change[2]; | |
| 69 /*! Probability of an impulse in the low and high loss states */ | |
| 70 double prob_impulse[2][2]; | |
| 71 | |
| 72 /*! Impulse height, based on MTU and bit rate */ | |
| 73 double impulse_height; | |
| 74 /*! Impulse decay coefficient for the single pole IIR filter. */ | |
| 75 double impulse_coeff; | |
| 76 | |
| 77 /*! Probability of packet loss due to occupancy. */ | |
| 78 double prob_packet_loss; | |
| 79 /*! Probability of packet loss due to a multiple access collision. */ | |
| 80 double prob_packet_collision_loss; | |
| 81 } g1050_segment_constants_t; | |
| 82 | |
| 83 /*! End-to-end constants, as defined in G.1050. */ | |
| 84 typedef struct | |
| 85 { | |
| 86 g1050_segment_constants_t segment[4]; | |
| 87 } g1050_constants_t; | |
| 88 | |
| 89 /*! The model definition for a LAN or access link segment */ | |
| 90 typedef struct | |
| 91 { | |
| 92 /*! Percentage occupancy of the media */ | |
| 93 double percentage_occupancy; | |
| 94 /*! MTU of the media */ | |
| 95 int mtu; | |
| 96 /*! Maximum jitter in the segment. */ | |
| 97 double max_jitter; | |
| 98 } g1050_segment_model_t; | |
| 99 | |
| 100 /*! The model definition for the core network (backbone) segment */ | |
| 101 typedef struct | |
| 102 { | |
| 103 /*! Basic delay of the backbone for regional paths */ | |
| 104 double base_regional_delay; | |
| 105 /*! Basic delay of the backbone for intercontinental paths */ | |
| 106 double base_intercontinental_delay; | |
| 107 /*! Percentage packet loss of the backbone */ | |
| 108 /*! Percentage packet loss of the backbone. */ | |
| 109 double percentage_packet_loss; | |
| 110 /*! Maximum jitter in the backbone. */ | |
| 111 double max_jitter; | |
| 112 /*! Interval between the backbone route flapping between two paths, in seconds. */ | |
| 113 double route_flap_interval; | |
| 114 /*! The difference in backbone delay between the two routes we flap between, in seconds. */ | |
| 115 double route_flap_delay; | |
| 116 /*! The interval between link failures. */ | |
| 117 double link_failure_interval; | |
| 118 /*! The duration of link failures. */ | |
| 119 double link_failure_duration; | |
| 120 /*! Probability of packet loss in the backbone. */ | |
| 121 double prob_packet_loss; | |
| 122 /*! Probability of a packet going out of sequence in the backbone. */ | |
| 123 double prob_oos; | |
| 124 } g1050_core_model_t; | |
| 125 | |
| 126 /*! The model definition for a complete end-to-end path */ | |
| 127 typedef struct | |
| 128 { | |
| 129 /*! The likelyhood of occurance probabilities for the A, B and C scenarios defined in G.1050 */ | |
| 130 int loo[3]; | |
| 131 g1050_segment_model_t sidea_lan; | |
| 132 g1050_segment_model_t sidea_access_link; | |
| 133 g1050_core_model_t core; | |
| 134 g1050_segment_model_t sideb_access_link; | |
| 135 g1050_segment_model_t sideb_lan; | |
| 136 } g1050_model_t; | |
| 137 | |
| 138 /*! The speed model for a complete end-to-end path */ | |
| 139 typedef struct | |
| 140 { | |
| 141 int sidea_lan_bit_rate; | |
| 142 int sidea_lan_multiple_access; | |
| 143 int sidea_access_link_bit_rate_ab; | |
| 144 int sidea_access_link_bit_rate_ba; | |
| 145 int sidea_access_link_qos_enabled; | |
| 146 int sideb_lan_bit_rate; | |
| 147 int sideb_lan_multiple_access; | |
| 148 int sideb_access_link_bit_rate_ab; | |
| 149 int sideb_access_link_bit_rate_ba; | |
| 150 int sideb_access_link_qos_enabled; | |
| 151 double loo; | |
| 152 } g1050_channel_speeds_t; | |
| 153 | |
| 154 /*! The model state for a LAN or access link segment */ | |
| 155 typedef struct | |
| 156 { | |
| 157 /*! The type of link, G1050_LAN_LINK or G_1050_ACCESS_LINK */ | |
| 158 int link_type; | |
| 159 /*! 1 if in the high loss state, or 0 if in the low loss state. */ | |
| 160 int high_loss; | |
| 161 | |
| 162 /*! The probability of a loss rate change, for both loss rate states. */ | |
| 163 double prob_loss_rate_change[2]; | |
| 164 /*! The probability of a impulse occuring, for both loss rate states. */ | |
| 165 double prob_impulse[2]; | |
| 166 | |
| 167 /*! The maximum permitted height of impulses. */ | |
| 168 double impulse_height; | |
| 169 /*! The impulse decay coefficient. */ | |
| 170 double impulse_coeff; | |
| 171 | |
| 172 /*! The basic serial delay due to the link. */ | |
| 173 double serial_delay; | |
| 174 /*! Peak jitter in the segment. */ | |
| 175 double max_jitter; | |
| 176 /*! The probability of packet loss. */ | |
| 177 double prob_packet_loss; | |
| 178 /*! The probability of packet loss due to collision. */ | |
| 179 double prob_packet_collision_loss; | |
| 180 /*! The maximum addition delay due to congestion. */ | |
| 181 double congestion_delay; | |
| 182 | |
| 183 /*! TRUE if QoS is enabled on the link. */ | |
| 184 int qos_enabled; | |
| 185 /*! TRUE if the link is a multiple access type (e.g. an ethernet hub). */ | |
| 186 int multiple_access; | |
| 187 | |
| 188 /*! The latest packet arrival time seen on the link. */ | |
| 189 double last_arrival_time; | |
| 190 | |
| 191 /*! 3 seconds of predicted delays for the link */ | |
| 192 double delays[3*G1050_TICKS_PER_SEC]; | |
| 193 | |
| 194 /*! A count of packets lost on the link. */ | |
| 195 uint32_t lost_packets; | |
| 196 /*! An extra debug count of packets lost on the link. */ | |
| 197 uint32_t lost_packets_2; | |
| 198 } g1050_segment_state_t; | |
| 199 | |
| 200 /*! The model state for the core network (backbone) segment */ | |
| 201 typedef struct | |
| 202 { | |
| 203 /* Router model. */ | |
| 204 int32_t route_flap_counter; | |
| 205 int32_t route_flap_interval; | |
| 206 double route_flap_delta; | |
| 207 | |
| 208 /* Link failure model. */ | |
| 209 int32_t link_failure_counter; | |
| 210 int32_t link_recovery_counter; | |
| 211 | |
| 212 int32_t link_failure_interval_ticks; | |
| 213 int32_t link_failure_duration_ticks; | |
| 214 | |
| 215 /*! Basic backbone delay */ | |
| 216 double base_delay; | |
| 217 /*! Peak jitter in the backbone delay */ | |
| 218 double max_jitter; | |
| 219 /*! Probability of packet loss in the backbone, in percent */ | |
| 220 double prob_packet_loss; | |
| 221 /*! Probability of a packet going out of sequence in the backbone. */ | |
| 222 double prob_oos; | |
| 223 | |
| 224 /*! The latest packet arrival time seen on the link. */ | |
| 225 double last_arrival_time; | |
| 226 double delay_delta; | |
| 227 | |
| 228 /*! 3 seconds of predicted delays for the link */ | |
| 229 double delays[3*G1050_TICKS_PER_SEC]; | |
| 230 | |
| 231 /*! A count of packets lost on the link. */ | |
| 232 uint32_t lost_packets; | |
| 233 /*! An extra debug count of packets lost on the link. */ | |
| 234 uint32_t lost_packets_2; | |
| 235 } g1050_core_state_t; | |
| 236 | |
| 237 /*! The definition of an element in the packet queue */ | |
| 238 typedef struct g1050_queue_element_s | |
| 239 { | |
| 240 struct g1050_queue_element_s *next; | |
| 241 struct g1050_queue_element_s *prev; | |
| 242 int seq_no; | |
| 243 double departure_time; | |
| 244 double arrival_time; | |
| 245 int len; | |
| 246 uint8_t pkt[]; | |
| 247 } g1050_queue_element_t; | |
| 248 | |
| 249 /*! The model definition for a complete end-to-end path */ | |
| 250 typedef struct | |
| 251 { | |
| 252 int packet_rate; | |
| 253 int packet_size; | |
| 254 float base_time; | |
| 255 g1050_segment_state_t segment[4]; | |
| 256 g1050_core_state_t core; | |
| 257 double arrival_times_1[3*G1050_TICKS_PER_SEC]; | |
| 258 double arrival_times_2[3*G1050_TICKS_PER_SEC]; | |
| 259 g1050_queue_element_t *first; | |
| 260 g1050_queue_element_t *last; | |
| 261 } g1050_state_t; | |
| 262 | |
| 263 extern g1050_constants_t g1050_constants[1]; | |
| 264 extern g1050_channel_speeds_t g1050_speed_patterns[168]; | |
| 265 extern g1050_model_t g1050_standard_models[9]; | |
| 266 | |
| 267 #ifdef __cplusplus | |
| 268 extern "C" | |
| 269 { | |
| 270 #endif | |
| 271 | |
| 272 SPAN_DECLARE(g1050_state_t *) g1050_init(int model, | |
| 273 int speed_pattern, | |
| 274 int packet_size, | |
| 275 int packet_rate); | |
| 276 | |
| 277 SPAN_DECLARE(void) g1050_dump_parms(int model, int speed_pattern); | |
| 278 | |
| 279 SPAN_DECLARE(int) g1050_put(g1050_state_t *s, | |
| 280 const uint8_t buf[], | |
| 281 int len, | |
| 282 int seq_no, | |
| 283 double departure_time); | |
| 284 | |
| 285 SPAN_DECLARE(int) g1050_get(g1050_state_t *s, | |
| 286 uint8_t buf[], | |
| 287 int max_len, | |
| 288 double current_time, | |
| 289 int *seq_no, | |
| 290 double *departure_time, | |
| 291 double *arrival_time); | |
| 292 | |
| 293 SPAN_DECLARE(void) g1050_queue_dump(g1050_state_t *s); | |
| 294 | |
| 295 #ifdef __cplusplus | |
| 296 } | |
| 297 #endif | |
| 298 | |
| 299 #endif | |
| 300 /*- End of file ------------------------------------------------------------*/ |
