Main Page | Class List | File List | Class Members | File Members

mux.h

Go to the documentation of this file.
00001 /* MUX.H */
00002 
00003 #ifndef _MUX_H_
00004 #define _MUX_H_
00005 
00006 #include "al_sending.h"
00007 #include "al_receiving.h"
00008 #include "channel.h"
00009 #include "mux.h"
00010 #include "med.h"
00011 #include "bch.h"
00012 
00013 
00014 /* new stuff */
00015 
00016 #define MUX_TABLE_SIZE  16
00017 
00018 #define DEF_MUX_HEADER 1
00019 #define DEF_MUX_SYNC_FLAG 32
00020 #define DEF_MUX_SYNC_THRESH 28
00021 
00022 #define DEF_MUX_LEVEL 1
00023 
00024 
00025 #define DEF_PAYLOAD_MIN 1
00026 #define DEF_PAYLOAD_MAX 128
00027 
00028 #define DEF_HEADER_CODE BCH15_5
00029 #define DEF_USE_MPL 0
00030 #define DEF_MPL_CODE BCH15_11
00031 
00032 #define DEF_INFO_FIELD_LENGTH  128    
00033 
00034 /* oldjunk */
00035 #define NO_INTERLEAVING   0 
00036 #define BIT_INTERLEAVING  1
00037 #define BYTE_INTERLEAVING 2
00038 
00039 #define DEF_HEADER_MC_LENGTH    4
00040 #define DEF_HEADER_CRC_LENGTH   3
00041 
00042 #define MAX_AL_SENDERS 10
00043 #define MAX_AL_RECEIVERS 10
00044 /* end oldjunk */
00045 
00046 
00047 /*****************************************************************************
00048  * Parameters shared between MUX and DEMUX                                   *
00049  *****************************************************************************/
00050 
00051 typedef struct {
00052   /*
00053    * Synchronization word length
00054    */
00055   int sync_flag_length;    /* 0, 8, 16, 24, 32 bits.  */
00056 
00057   int use_double_flag;     /* for level2, 16 bit flag, will double it */
00058 
00059   int sync_threshold;      /* bits required to have a valid sync flag */
00060 
00061   int mpl_sync_threshold;  /* threshold when using mpl from previous packet */
00062   bch_type header_code;
00063 
00064   int use_mpl;
00065   bch_type mpl_code;
00066 
00067   int payload_min;
00068   int payload_max;
00069 
00070   int info_field_length;                         /* changes each packet . */
00071 
00072   /*
00073    * The Multiplex Table.
00074    */ 
00075   mux_table_entry mux_table[MUX_TABLE_SIZE];         /* table of MultiplexEntryDescriptors */
00076   int mux_table_size;                 /* number of entries in mux table */
00077 
00078   float **mt_ratios;                  /* ratio of bytes to total bytes
00079                                          per channel per multiplex code */
00080 
00081   int **mt_bytes;                     /* number of bytes to send per channel 
00082                                          per multiplex code */
00083 
00084   char stat_file[MAX_FILENAME_LENGTH];  /* filename for outputting statistics */
00085 
00086   int level;                          /* level 1 or level 2 */
00087   
00088   int mpl_t;                          /* error correction capability of mpl bch */
00089   int head_t;                         /* error correction capability of hdr bch */
00090 } mux_parameters;
00091 
00092 
00093 typedef struct {
00094   char name[41];        /* A label like "Remote Mux" or "Local Mux" */
00095 
00096   /* Params shared with corresponding DEMUX */
00097   mux_parameters *params;
00098 
00099   /************************************************************************** 
00100    * MUX Specific Parameters                                                *
00101    **************************************************************************/
00102 
00103   al_sending_entity *al_senders[MAX_AL_SENDERS]; /* read MUX-SDU's from here*/
00104 
00105   int num_al_senders;
00106 
00107   channel *output;                       /* write MUX-PDUs here */
00108 
00109   int wait_time;                    /* time to wait between packets. */
00110 
00111   int packetsSent;                  /* number of packets it has sent */
00112 } mux;
00113 
00114 
00115 /* Function Prototypes */
00116 
00117 mux_parameters *new_mux_parameters(char *name);
00118 /* 
00119  * This function is defined in muxstuff.c
00120  */
00121 
00122 mux *new_mux(char *name);
00123 /*
00124  * mallocs a new mux structure
00125  */
00126 
00127 static int bytes_ok(int mt_bytes[], int buffer_bytes[], int d, mux *m);
00128      /*
00129       * Returns 1 iff for i=0, i<d, mt_bytes[i] <= buffer_bytes[i]
00130       *           also, number of channels described in the MED must
00131       *           equal the number of channels.  Ie. if you only
00132       *           have LCN0 and LCN1, and your MED is
00133       *           {LCN1 RC 10, LCN2 RC UCF} this function returns 0.
00134       *
00135       * Should be used like this:
00136       *
00137       * if (bytes_ok(mt_bytes, al_buffer, num_channels, m);
00138       */
00139 
00140 float ratio_difference(float a[], float b[], int d);
00141      /*
00142       * Computes the scalar difference between a[] and b[]
00143       * (i.e. sum(i=0, d-1, (abs(b[i] - a[i]))).
00144       *
00145       * Should be used like this:
00146       *
00147       * diff = compute_difference(mt_ratios, al_ratios, num_channels);
00148       */
00149 
00150 static void print_int(int x);
00151 /*
00152  * Prints a 32-bit representation of an integer
00153  */
00154 
00155 static void set_payload_size(mux *m);
00156 /*
00157  * sets up a random payload length
00158  */
00159 
00160 void multiplex(mux *m, int num_channels);
00161 /*
00162  * This is the main mux function
00163  *   it chooses the best multiplex code based on the buffer
00164  *   levels, and sends the appropriate mux-pdu structure 
00165  */
00166 
00167 void close_mux(mux *m);
00168 /*
00169  * prints out the mux stats
00170  */
00171 
00172 #endif

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1