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?
30The ITU G.1050 specification defines a model of an IP network, appropriate
31for the testing of how streaming media woud behave across the internet. The
32model 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)
38The impairments typical of these segments at various service levels are modelled.
398 standard service level behaviours are defined, covering lightly loaded to heavily
40congested levels. 168 standard sets of link speeds are defined, covering typical
41wired and wireless LAN, broadband access link, and backbone characteristics.
42
43The G.1050 model is suitable for testing the behaviour of RTP, UDPTL and other streaming
44protocols 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. */
63typedef struct
64{
65 /*! Probability of changing from low to high and high to low loss states */
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. */
82typedef struct
83{
86
87/*! The model definition for a LAN or access link segment */
88typedef 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 */
99typedef 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. */
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 */
124typedef 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;
131 g1050_segment_model_t sideb_access_link;
132 g1050_segment_model_t sideb_lan;
134
135/*! The speed model for a complete end-to-end path */
136typedef 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 */
152typedef 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. */
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. */
171 /*! Peak jitter in the segment. */
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. */
196
197/*! The model state for the core network (backbone) segment */
198typedef 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 */
214 /*! Peak jitter in the backbone delay */
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. */
233
234/*! The definition of an element in the packet queue */
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 */
247typedef struct
248{
249 int packet_rate;
250 int packet_size;
251 float base_time;
252 g1050_segment_state_t segment[4];
254 double arrival_times_1[3*G1050_TICKS_PER_SEC];
255 double arrival_times_2[3*G1050_TICKS_PER_SEC];
259
260extern g1050_constants_t g1050_constants[1];
261extern g1050_channel_speeds_t g1050_speed_patterns[168];
262extern g1050_model_t g1050_standard_models[9];
263
264#ifdef __cplusplus
265extern "C"
266{
267#endif
268
269SPAN_DECLARE(g1050_state_t *) g1050_init(int model,
270 int speed_pattern,
271 int packet_size,
272 int packet_rate);
273
274SPAN_DECLARE(int) g1050_free(g1050_state_t *s);
275
276SPAN_DECLARE(void) g1050_dump_parms(int model, int speed_pattern);
277
278SPAN_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
284SPAN_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
292SPAN_DECLARE(void) g1050_queue_dump(g1050_state_t *s);
293
294#ifdef __cplusplus
295}
296#endif
297
298#endif
299/*- End of file ------------------------------------------------------------*/
struct g1050_queue_element_s g1050_queue_element_t
Definition g1050.h:137
Definition g1050.h:83
Definition g1050.h:100
double prob_oos
Definition g1050.h:120
double base_intercontinental_delay
Definition g1050.h:104
double route_flap_delay
Definition g1050.h:112
double base_regional_delay
Definition g1050.h:102
double route_flap_interval
Definition g1050.h:110
double link_failure_duration
Definition g1050.h:116
double max_jitter
Definition g1050.h:108
double percentage_packet_loss
Definition g1050.h:106
double prob_packet_loss
Definition g1050.h:118
double link_failure_interval
Definition g1050.h:114
Definition g1050.h:199
double base_delay
Definition g1050.h:213
uint32_t lost_packets
Definition g1050.h:229
double max_jitter
Definition g1050.h:215
double prob_oos
Definition g1050.h:219
double last_arrival_time
Definition g1050.h:222
double delays[3 *1000]
Definition g1050.h:226
uint32_t lost_packets_2
Definition g1050.h:231
double prob_packet_loss
Definition g1050.h:217
Definition g1050.h:125
int loo[3]
Definition g1050.h:127
Definition g1050.h:236
Definition g1050.h:64
double prob_impulse[2][2]
Definition g1050.h:68
double impulse_decay_coeff
Definition g1050.h:73
double prob_packet_loss
Definition g1050.h:76
double impulse_height
Definition g1050.h:71
double prob_loss_rate_change[2]
Definition g1050.h:66
double prob_packet_collision_loss
Definition g1050.h:78
Definition g1050.h:89
int mtu
Definition g1050.h:93
double percentage_occupancy
Definition g1050.h:91
double max_jitter
Definition g1050.h:95
Definition g1050.h:153
int qos_enabled
Definition g1050.h:181
double impulse_height
Definition g1050.h:165
double prob_packet_collision_loss
Definition g1050.h:176
double serial_delay
Definition g1050.h:170
double prob_packet_loss
Definition g1050.h:174
uint32_t lost_packets
Definition g1050.h:192
uint32_t lost_packets_2
Definition g1050.h:194
int multiple_access
Definition g1050.h:183
double impulse_decay_coeff
Definition g1050.h:167
int link_type
Definition g1050.h:155
double max_jitter
Definition g1050.h:172
int high_loss
Definition g1050.h:157
double delays[3 *1000]
Definition g1050.h:189
double last_arrival_time
Definition g1050.h:186
double congestion_delay
Definition g1050.h:178
double prob_loss_rate_change[2]
Definition g1050.h:160
double prob_impulse[2]
Definition g1050.h:162
Definition g1050.h:248