/* $Id: mcl_data.h,v 1.5 2003/10/27 09:55:47 roca Exp $ */ /* * Copyright (c) 1999-2003 INRIA - Universite Paris 6 - All rights reserved * (main author: Vincent Roca - vincent.roca@inrialpes.fr) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #ifndef MCL_DATA_H /* { */ #define MCL_DATA_H /****** data structures ******/ /* * ALC/LCT terminology MCL terminology * ------------------- --------------- * object ADU (adu_t) * block block (block_t) * data (or source) symbol DU (du_t, is_fec=0) * FEC symbol DU (du_t, is_fec=1) */ /* * Application Data Unit (ADU) * They are the unit of data submitted by the sending application * in an mcl_send[to] call. * The ADU boundaries are preserved and communicated to the receivers. * Both sender and receivers keep a linked list of ADUs. */ typedef struct adu { struct adu *prev, *next; u_int32_t seq; /* seq nb of this ADU */ u_int32_t FDTinstanceID; /* FDT instance ID if FDT (seq==0) */ u_int32_t len; /* number of bytes in this ADU */ u_int32_t padded_len; /* len with optional 0 padding */ struct block *block_head; /* first block of this ADU in list */ u_int32_t block_nb; /* number of blocks in this ADU */ u_int8_t fec_encoding_id;/* FEC enc. id used for this ADU */ u_int8_t fec_instance_id;/* FEC inst. id used for this ADU */ u_int16_t symbol_len; /* full-sized symbol size in bytes */ /* valid for all DUs of this ADU */ class mcl_addr addr; /* ADU received from or destined to */ bool addr_valid; /* boolean: true if the addr class is */ /* valid, ie has been initialized */ /* fields only used by the sender */ char *data; /* ptr to data buffer */ char in_txtab; /* boolean: 1 if there is at least one*/ /* du waiting to be sent in txtab */ #if defined(VIRTUAL_TX_MEM) || defined(VIRTUAL_RX_MEM) union { #ifdef VIRTUAL_TX_MEM /* field only used by the sender */ struct vtm_info vtm_info_u; /* adu/vtm correspondance */ #endif #ifdef VIRTUAL_RX_MEM /* field only used by the receiver */ struct vrm_info vrm_info_u; /* adu/vrm correspondance */ #endif } vxm; #endif /* VIRTUAL_TX_MEM | VIRTUAL_RX_MEM */ /* fields only used by the receivers */ char ia_adu; /* boolean: 1 if implicitly announced */ char rx_status; /* rx status (completed/delivered/..) */ } adu_t; /* possible values of the adu->rx_status field */ #define ADU_STATUS_NIL 0 /* void status */ #define ADU_STATUS_IN_PROGRESS 1 /* not yet ready */ #define ADU_STATUS_COMPLETED 2 /* received all DUs from all blocks */ #define ADU_STATUS_DECODED 3 /* COMPLETED and FEC decoding done */ #define ADU_STATUS_DELIVERED 4 /* sent to the receiving application */ /* * Block * They are the result of the segmentation of ADUs into several * blocks of size appropriate to the FEC codec in use. */ typedef struct block { struct adu *adu; /* ADU to which this block belongs */ u_int32_t seq; /* block sequence number */ u_int32_t len; /* number of bytes in this block */ struct du *du_head; /* first DU of this block in list */ u_int32_t k; /* nb of DUs for this block (k param) */ #ifdef FEC struct du *fec_du_head; /* first FEC DU of this block in list */ u_int32_t fec_du_nb_in_list; /* nb of FEC DUs in this block */ /* at a source, it's the n-k param. */ #ifdef LDPC_FEC u_int16_t fec_key; /* LDGM/LDPC specific: random seed */ u_int32_t n; /* LDGM/LDPC specific: n parameter */ #endif /* LDPC_FEC */ #endif /* fields only used by the receivers */ u_int32_t du_rx; /* nb of non-FEC DU recvd (!= k) */ /* or decoded (in case of LDPC) */ char rx_status; /* rx status (completed/decoded/..) */ #ifdef LDPC_FEC class LDPCFecSession *ldpc_ses; /* LDPC context, used by decoder */ void **pkt_canvas; /* ptrs to pkt table, used by decoder */ struct ldpc_callback_context* callback_ctxt; /* carries context info required by */ /* the LDPC callback function */ #endif /* LDPC_FEC */ } block_t; /* possible values of the du->rx_status field */ #define BLK_STATUS_NIL 0 /* void status */ #define BLK_STATUS_IN_PROGRESS 1 /* not yet ready */ #define BLK_STATUS_COMPLETED 2 /* received all DUs from all blocks */ #define BLK_STATUS_DECODED 3 /* COMPLETED and FEC decoding done */ /* * Data Unit (DU) * They are the result of the segmentation of a block (i.e. ADU chunck) * and identify a sequence of bytes. * They can either contain plain data or redundant FEC data. * They are the data payload of the packets sent. * Used both by the sending and receiving sides. */ typedef struct du { struct du *prev, *next; /* links used only by the receiver! */ struct block *block; /* block to which this DU belongs */ char *data; /* ptr to data in buffer */ u_int32_t seq; /* sequence number of this DU */ u_short len; /* number of bytes in this DU */ #ifdef FEC bool is_fec; /* true if this is a FEC DU */ #endif /* rx specific field */ class mcl_rx_pkt *pkt; // object containing the packet recvd #if defined(VIRTUAL_TX_MEM) || defined(VIRTUAL_RX_MEM) union { #ifdef VIRTUAL_TX_MEM /* field only used by the sender */ struct vtm_info vtm_info_u; /* adu/vtm correspondance */ #endif #ifdef VIRTUAL_RX_MEM /* field only used by the receiver */ struct vrm_info vrm_info_u; /* adu/vrm correspondance */ #endif } vxm; #endif /* VIRTUAL_TX_MEM | VIRTUAL_RX_MEM */ } du_t; #if defined(VIRTUAL_TX_MEM) || defined(VIRTUAL_RX_MEM) /* easy access for the adu_t and du_t union members */ #define vtm_info vxm.vtm_info_u #define vrm_info vxm.vrm_info_u #endif /* VIRTUAL_TX_MEM | VIRTUAL_RX_MEM */ /* * Table of planned tx on a layer * Each struct contains at most NB_TXTAB_ENTRIES each, more struct follow * if required. All DUs of a txtab are sent the same number of times. */ #define NB_TXTAB_ENTRIES 1000 typedef struct txtab { struct txtab *prev, *next; u_int32_t wr_index; /* index of next free DU in txtab */ u_int32_t tx_index; /* index of next DU to send in txtab */ int rem_tx; /* remaining number of tx for each du */ struct du *du_tab[NB_TXTAB_ENTRIES]; /* table of DUs to send */ } txtab_t; /* * Signaling list used by the sender to prepare ALC extension headers */ typedef struct sig_tab { struct sig_tab *next; int eh_type; /* EXT_CCI, ... SIG_NONEWADU, ... */ char *buf; /* complementary info, or full ALC EH */ int len; /* future ALC EH has this len (bytes) */ int target_lvl; /* to send on this layer, any if -1 */ int rem2send; /* nb of times it can still be sent */ /*struct sockaddr *saddr;*/ /* destination, otherwise default lvl */ class mcl_addr *saddr; /* destination, otherwise default lvl */ int saddr_len; /* and associated len */ } sig_tab_t; #endif /* } MCL_DATA_H */