spandsp 0.0.6

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 */
71 double impulse_height;
72 /*! Impulse decay coefficient for the single pole IIR filter. */
73 double impulse_coeff;
74
75 /*! Probability of packet loss due to occupancy. */
76 double prob_packet_loss;
77 /*! Probability of packet loss due to a multiple access collision. */
78 double prob_packet_collision_loss;
79} g1050_segment_constants_t;
80
81/*! End-to-end constants, as defined in G.1050. */
82 typedef struct
83{
84 g1050_segment_constants_t segment[4];
85} g1050_constants_t;
86
87/*! The model definition for a LAN or access link segment */
88 typedef struct
89{
90 /*! Percentage occupancy of the media */
91 double percentage_occupancy;
92 /*! MTU of the media */
93 int mtu;
94 /*! Maximum jitter in the segment. */
95 double max_jitter;
96} g1050_segment_model_t;
97
98/*! The model definition for the core network (backbone) segment */
99 typedef struct
100{
101 /*! Basic delay of the backbone for regional paths */
102 double base_regional_delay;
103 /*! Basic delay of the backbone for intercontinental paths */
104 double base_intercontinental_delay;
105 /*! Percentage packet loss of the backbone */
106 /*! Percentage packet loss of the backbone. */
107 double percentage_packet_loss;
108 /*! Maximum jitter in the backbone. */
109 double max_jitter;
110 /*! Interval between the backbone route flapping between two paths, in seconds. */
111 double route_flap_interval;
112 /*! The difference in backbone delay between the two routes we flap between, in seconds. */
113 double route_flap_delay;
114 /*! The interval between link failures. */
115 double link_failure_interval;
116 /*! The duration of link failures. */
117 double link_failure_duration;
118 /*! Probability of packet loss in the backbone. */
119 double prob_packet_loss;
120 /*! Probability of a packet going out of sequence in the backbone. */
121 double prob_oos;
122} g1050_core_model_t;
123
124/*! The model definition for a complete end-to-end path */
125 typedef struct
126{
127 /*! The likelyhood of occurance probabilities for the A, B and C scenarios defined in G.1050 */
128 int loo[3];
129 g1050_segment_model_t sidea_lan;
130 g1050_segment_model_t sidea_access_link;
131 g1050_core_model_t core;
132 g1050_segment_model_t sideb_access_link;
133 g1050_segment_model_t sideb_lan;
134} g1050_model_t;
135
136/*! The speed model for a complete end-to-end path */
137 typedef struct
138{
139 int sidea_lan_bit_rate;
140 int sidea_lan_multiple_access;
141 int sidea_access_link_bit_rate_ab;
142 int sidea_access_link_bit_rate_ba;
143 int sidea_access_link_qos_enabled;
144 int sideb_lan_bit_rate;
145 int sideb_lan_multiple_access;
146 int sideb_access_link_bit_rate_ab;
147 int sideb_access_link_bit_rate_ba;
148 int sideb_access_link_qos_enabled;
149 double loo;
150} g1050_channel_speeds_t;
151
152/*! The model state for a LAN or access link segment */
153 typedef struct
154{
155 /*! The type of link, G1050_LAN_LINK or G_1050_ACCESS_LINK */
156 int link_type;
157 /*! 1 if in the high loss state, or 0 if in the low loss state. */
158 int high_loss;
159
160 /*! The probability of a loss rate change, for both loss rate states. */
161 double prob_loss_rate_change[2];
162 /*! The probability of a impulse occuring, for both loss rate states. */
163 double prob_impulse[2];
164
165 /*! The maximum permitted height of impulses. */
166 double impulse_height;
167 /*! The impulse decay coefficient. */
168 double impulse_coeff;
169
170 /*! The basic serial delay due to the link. */
171 double serial_delay;
172 /*! Peak jitter in the segment. */
173 double max_jitter;
174 /*! The probability of packet loss. */
175 double prob_packet_loss;
176 /*! The probability of packet loss due to collision. */
177 double prob_packet_collision_loss;
178 /*! The maximum addition delay due to congestion. */
179 double congestion_delay;
180
181 /*! TRUE if QoS is enabled on the link. */
182 int qos_enabled;
183 /*! TRUE if the link is a multiple access type (e.g. an ethernet hub). */
184 int multiple_access;
185
186 /*! The latest packet arrival time seen on the link. */
187 double last_arrival_time;
188
189 /*! 3 seconds of predicted delays for the link */
190 double delays[3*G1050_TICKS_PER_SEC];
191
192 /*! A count of packets lost on the link. */
193 uint32_t lost_packets;
194 /*! An extra debug count of packets lost on the link. */
195 uint32_t lost_packets_2;
196} g1050_segment_state_t;
197
198/*! The model state for the core network (backbone) segment */
199 typedef struct
200{
201 /* Router model. */
202 int32_t route_flap_counter;
203 int32_t route_flap_interval;
204 double route_flap_delta;
205
206 /* Link failure model. */
207 int32_t link_failure_counter;
208 int32_t link_recovery_counter;
209
210 int32_t link_failure_interval_ticks;
211 int32_t link_failure_duration_ticks;
212
213 /*! Basic backbone delay */
214 double base_delay;
215 /*! Peak jitter in the backbone delay */
216 double max_jitter;
217 /*! Probability of packet loss in the backbone, in percent */
218 double prob_packet_loss;
219 /*! Probability of a packet going out of sequence in the backbone. */
220 double prob_oos;
221
222 /*! The latest packet arrival time seen on the link. */
223 double last_arrival_time;
224 double delay_delta;
225
226 /*! 3 seconds of predicted delays for the link */
227 double delays[3*G1050_TICKS_PER_SEC];
228
229 /*! A count of packets lost on the link. */
230 uint32_t lost_packets;
231 /*! An extra debug count of packets lost on the link. */
232 uint32_t lost_packets_2;
233} g1050_core_state_t;
234
235/*! The definition of an element in the packet queue */
236 typedef struct g1050_queue_element_s
237{
238 struct g1050_queue_element_s *next;
239 struct g1050_queue_element_s *prev;
240 int seq_no;
241 double departure_time;
242 double arrival_time;
243 int len;
244 uint8_t pkt[];
245} g1050_queue_element_t;
246
247/*! The model definition for a complete end-to-end path */
248 typedef struct
249{
250 int packet_rate;
251 int packet_size;
252 float base_time;
253 g1050_segment_state_t segment[4];
254 g1050_core_state_t core;
255 double arrival_times_1[3*G1050_TICKS_PER_SEC];
256 double arrival_times_2[3*G1050_TICKS_PER_SEC];
257 g1050_queue_element_t *first;
258 g1050_queue_element_t *last;
259} g1050_state_t;
260
261 extern g1050_constants_t g1050_constants[1];
262 extern g1050_channel_speeds_t g1050_speed_patterns[168];
263 extern g1050_model_t g1050_standard_models[9];
264
265#ifdef __cplusplus
266 extern "C"
267{
268#endif
269
270SPAN_DECLARE(g1050_state_t *) g1050_init(int model,
271 int speed_pattern,
272 int packet_size,
273 int packet_rate);
274
275SPAN_DECLARE(void) g1050_dump_parms(int model, int speed_pattern);
276
277SPAN_DECLARE(int) g1050_put(g1050_state_t *s,
278 const uint8_t buf[],
279 int len,
280 int seq_no,
281 double departure_time);
282
283SPAN_DECLARE(int) g1050_get(g1050_state_t *s,
284 uint8_t buf[],
285 int max_len,
286 double current_time,
287 int *seq_no,
288 double *departure_time,
289 double *arrival_time);
290
291SPAN_DECLARE(void) g1050_queue_dump(g1050_state_t *s);
292
293#ifdef __cplusplus
294}
295#endif
296
297#endif
298/*- End of file ------------------------------------------------------------*/
g1050_queue_element_t
struct g1050_queue_element_s g1050_queue_element_t
g1050_channel_speeds_t
Definition g1050.h:138
g1050_constants_t
Definition g1050.h:83
g1050_core_model_t
Definition g1050.h:100
g1050_core_model_t::prob_oos
double prob_oos
Definition g1050.h:121
g1050_core_model_t::base_intercontinental_delay
double base_intercontinental_delay
Definition g1050.h:104
g1050_core_model_t::route_flap_delay
double route_flap_delay
Definition g1050.h:113
g1050_core_model_t::base_regional_delay
double base_regional_delay
Definition g1050.h:102
g1050_core_model_t::route_flap_interval
double route_flap_interval
Definition g1050.h:111
g1050_core_model_t::link_failure_duration
double link_failure_duration
Definition g1050.h:117
g1050_core_model_t::max_jitter
double max_jitter
Definition g1050.h:109
g1050_core_model_t::percentage_packet_loss
double percentage_packet_loss
Definition g1050.h:107
g1050_core_model_t::prob_packet_loss
double prob_packet_loss
Definition g1050.h:119
g1050_core_model_t::link_failure_interval
double link_failure_interval
Definition g1050.h:115
g1050_core_state_t
Definition g1050.h:200
g1050_core_state_t::base_delay
double base_delay
Definition g1050.h:214
g1050_core_state_t::lost_packets
uint32_t lost_packets
Definition g1050.h:230
g1050_core_state_t::max_jitter
double max_jitter
Definition g1050.h:216
g1050_core_state_t::prob_oos
double prob_oos
Definition g1050.h:220
g1050_core_state_t::last_arrival_time
double last_arrival_time
Definition g1050.h:223
g1050_core_state_t::delays
double delays[3 *1000]
Definition g1050.h:227
g1050_core_state_t::lost_packets_2
uint32_t lost_packets_2
Definition g1050.h:232
g1050_core_state_t::prob_packet_loss
double prob_packet_loss
Definition g1050.h:218
g1050_model_t
Definition g1050.h:126
g1050_model_t::loo
int loo[3]
Definition g1050.h:128
g1050_queue_element_s
Definition g1050.h:237
g1050_segment_constants_t
Definition g1050.h:64
g1050_segment_constants_t::prob_impulse
double prob_impulse[2][2]
Definition g1050.h:68
g1050_segment_constants_t::prob_packet_loss
double prob_packet_loss
Definition g1050.h:76
g1050_segment_constants_t::impulse_height
double impulse_height
Definition g1050.h:71
g1050_segment_constants_t::prob_loss_rate_change
double prob_loss_rate_change[2]
Definition g1050.h:66
g1050_segment_constants_t::prob_packet_collision_loss
double prob_packet_collision_loss
Definition g1050.h:78
g1050_segment_constants_t::impulse_coeff
double impulse_coeff
Definition g1050.h:73
g1050_segment_model_t
Definition g1050.h:89
g1050_segment_model_t::mtu
int mtu
Definition g1050.h:93
g1050_segment_model_t::percentage_occupancy
double percentage_occupancy
Definition g1050.h:91
g1050_segment_model_t::max_jitter
double max_jitter
Definition g1050.h:95
g1050_segment_state_t
Definition g1050.h:154
g1050_segment_state_t::qos_enabled
int qos_enabled
Definition g1050.h:182
g1050_segment_state_t::impulse_height
double impulse_height
Definition g1050.h:166
g1050_segment_state_t::prob_packet_collision_loss
double prob_packet_collision_loss
Definition g1050.h:177
g1050_segment_state_t::serial_delay
double serial_delay
Definition g1050.h:171
g1050_segment_state_t::prob_packet_loss
double prob_packet_loss
Definition g1050.h:175
g1050_segment_state_t::lost_packets
uint32_t lost_packets
Definition g1050.h:193
g1050_segment_state_t::lost_packets_2
uint32_t lost_packets_2
Definition g1050.h:195
g1050_segment_state_t::impulse_coeff
double impulse_coeff
Definition g1050.h:168
g1050_segment_state_t::multiple_access
int multiple_access
Definition g1050.h:184
g1050_segment_state_t::link_type
int link_type
Definition g1050.h:156
g1050_segment_state_t::max_jitter
double max_jitter
Definition g1050.h:173
g1050_segment_state_t::high_loss
int high_loss
Definition g1050.h:158
g1050_segment_state_t::delays
double delays[3 *1000]
Definition g1050.h:190
g1050_segment_state_t::last_arrival_time
double last_arrival_time
Definition g1050.h:187
g1050_segment_state_t::congestion_delay
double congestion_delay
Definition g1050.h:179
g1050_segment_state_t::prob_loss_rate_change
double prob_loss_rate_change[2]
Definition g1050.h:161
g1050_segment_state_t::prob_impulse
double prob_impulse[2]
Definition g1050.h:163
g1050_state_t
Definition g1050.h:249