spandsp 0.0.6
rfc2198_sim.h
Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * rfc2198_sim.h - Simulate the behaviour of RFC2198 (or UDPTL) redundancy.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2007 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  */
00025 
00026 /*! \file */
00027 
00028 /*! \page rfc2198_model_page RFC2198 simulation
00029 \section rfc2198_model_page_sec_1 What does it do?
00030 */
00031 
00032 #if !defined(_RFC2198_SIM_H_)
00033 #define _RFC2198_SIM_H_
00034 
00035 /*! The definition of an element in the packet queue */
00036 typedef struct rfc2198_sim_queue_element_s
00037 {
00038     struct rfc2198_sim_queue_element_s *next;
00039     struct rfc2198_sim_queue_element_s *prev;
00040     int seq_no;
00041     double departure_time;
00042     double arrival_time;
00043     int len;
00044     uint8_t pkt[];
00045 } rfc2198_sim_queue_element_t;
00046 
00047 /*! The model definition for a complete end-to-end path */
00048 typedef struct
00049 {
00050     int redundancy_depth;
00051     int next_seq_no;
00052     g1050_state_t *g1050;
00053     rfc2198_sim_queue_element_t *first;
00054     rfc2198_sim_queue_element_t *last;
00055     uint8_t tx_pkt[32][1024];
00056     int tx_pkt_len[32];
00057     int tx_pkt_seq_no[32];
00058     int next_pkt;
00059     uint8_t rx_pkt[32][1024];
00060     int rx_pkt_len[32];
00061     int rx_pkt_seq_no[32];
00062     int rx_queued_pkts;
00063 } rfc2198_sim_state_t;
00064 
00065 #ifdef  __cplusplus
00066 extern "C"
00067 {
00068 #endif
00069 
00070 SPAN_DECLARE(rfc2198_sim_state_t *) rfc2198_sim_init(int model,
00071                                                      int speed_pattern,
00072                                                      int packet_size,
00073                                                      int packet_rate,
00074                                                      int redundancy_depth);
00075 
00076 SPAN_DECLARE(int) rfc2198_sim_put(rfc2198_sim_state_t *s,
00077                                   const uint8_t buf[],
00078                                   int len,
00079                                   int seq_no,
00080                                   double departure_time);
00081 
00082 SPAN_DECLARE(int) rfc2198_sim_get(rfc2198_sim_state_t *s,
00083                                   uint8_t buf[],
00084                                   int max_len,
00085                                   double current_time,
00086                                   int *seq_no,
00087                                   double *departure_time,
00088                                   double *arrival_time);
00089 
00090 #ifdef  __cplusplus
00091 }
00092 #endif
00093 
00094 #endif
00095 /*- End of file ------------------------------------------------------------*/