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