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?
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 */
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. */
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 */
106 /*! Percentage packet loss of the backbone. */
108 /*! Maximum jitter in the backbone. */
110 /*! Interval between the backbone route flapping between two paths, in seconds. */
112 /*! The difference in backbone delay between the two routes we flap between, in seconds. */
114 /*! The interval between link failures. */
116 /*! The duration of link failures. */
118 /*! Probability of packet loss in the backbone. */
120 /*! Probability of a packet going out of sequence in the backbone. */
121 double prob_oos;
123
124/*! The model definition for a complete end-to-end path */
125typedef 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;
132 g1050_segment_model_t sideb_access_link;
133 g1050_segment_model_t sideb_lan;
135
136/*! The speed model for a complete end-to-end path */
137typedef 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;
151
152/*! The model state for a LAN or access link segment */
153typedef struct
154{
155 /*! The type of link, G1050_LAN_LINK or G_1050_ACCESS_LINK */
157 /*! 1 if in the high loss state, or 0 if in the low loss state. */
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. */
167 /*! The impulse decay coefficient. */
169
170 /*! The basic serial delay due to the link. */
172 /*! Peak jitter in the segment. */
174 /*! The probability of packet loss. */
176 /*! The probability of packet loss due to collision. */
178 /*! The maximum addition delay due to congestion. */
180
181 /*! TRUE if QoS is enabled on the link. */
183 /*! TRUE if the link is a multiple access type (e.g. an ethernet hub). */
185
186 /*! The latest packet arrival time seen on the link. */
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. */
197
198/*! The model state for the core network (backbone) segment */
199typedef 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 */
215 /*! Peak jitter in the backbone delay */
217 /*! Probability of packet loss in the backbone, in percent */
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. */
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. */
234
235/*! The definition of an element in the packet queue */
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[];
246
247/*! The model definition for a complete end-to-end path */
248typedef struct
249{
250 int packet_rate;
251 int packet_size;
252 float base_time;
253 g1050_segment_state_t segment[4];
255 double arrival_times_1[3*G1050_TICKS_PER_SEC];
256 double arrival_times_2[3*G1050_TICKS_PER_SEC];
260
261extern g1050_constants_t g1050_constants[1];
262extern g1050_channel_speeds_t g1050_speed_patterns[168];
263extern g1050_model_t g1050_standard_models[9];
264
265#ifdef __cplusplus
266extern "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 ------------------------------------------------------------*/
struct g1050_queue_element_s g1050_queue_element_t
Definition: g1050.h:138
Definition: g1050.h:83
Definition: g1050.h:100
double prob_oos
Definition: g1050.h:121
double base_intercontinental_delay
Definition: g1050.h:104
double route_flap_delay
Definition: g1050.h:113
double base_regional_delay
Definition: g1050.h:102
double route_flap_interval
Definition: g1050.h:111
double link_failure_duration
Definition: g1050.h:117
double max_jitter
Definition: g1050.h:109
double percentage_packet_loss
Definition: g1050.h:107
double prob_packet_loss
Definition: g1050.h:119
double link_failure_interval
Definition: g1050.h:115
Definition: g1050.h:200
double base_delay
Definition: g1050.h:214
uint32_t lost_packets
Definition: g1050.h:230
double max_jitter
Definition: g1050.h:216
double prob_oos
Definition: g1050.h:220
double last_arrival_time
Definition: g1050.h:223
uint32_t lost_packets_2
Definition: g1050.h:232
double prob_packet_loss
Definition: g1050.h:218
Definition: g1050.h:126
Definition: g1050.h:237
Definition: g1050.h:64
double prob_packet_loss
Definition: g1050.h:76
double impulse_height
Definition: g1050.h:71
double prob_packet_collision_loss
Definition: g1050.h:78
double impulse_coeff
Definition: g1050.h:73
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:154
int qos_enabled
Definition: g1050.h:182
double impulse_height
Definition: g1050.h:166
double prob_packet_collision_loss
Definition: g1050.h:177
double serial_delay
Definition: g1050.h:171
double prob_packet_loss
Definition: g1050.h:175
uint32_t lost_packets
Definition: g1050.h:193
uint32_t lost_packets_2
Definition: g1050.h:195
double impulse_coeff
Definition: g1050.h:168
int multiple_access
Definition: g1050.h:184
int link_type
Definition: g1050.h:156
double max_jitter
Definition: g1050.h:173
int high_loss
Definition: g1050.h:158
double last_arrival_time
Definition: g1050.h:187
double congestion_delay
Definition: g1050.h:179
Definition: g1050.h:249