alc_rx.c File Reference

ALC level receiving. More...

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <math.h>
#include <assert.h>
#include <winsock2.h>
#include <process.h>
#include <io.h>
#include "defines.h"
#include "alc_rx.h"
#include "alc_channel.h"
#include "mad_rlc.h"
#include "lct_hdr.h"
#include "null_fec.h"
#include "xor_fec.h"
#include "rs_fec.h"
#include "utils.h"
#include "transport.h"
#include "alc_list.h"

Include dependency graph for alc_rx.c:

Go to the source code of this file.

Functions

int analyze_packet (char *data, int len, alc_channel_t *ch)
int recv_packet (alc_session_t *s)
void * rx_socket_thread (void *ch)
void join_rx_socket_thread (alc_channel_t *ch)
void * rx_thread (void *s)
char * alc_recv (int s_id, unsigned long long toi, unsigned long long *data_len, int *retval)
char * alc_recv2 (int s_id, unsigned long long *toi, unsigned long long *data_len, int *retval)
char * alc_recv3 (int s_id, unsigned long long *toi, int *retval)
char * fdt_recv (int s_id, unsigned long long *data_len, int *retval, unsigned char *content_enc_algo, int *fdt_instance_id)
trans_obj_tobject_exist (unsigned long long toi, alc_session_t *s, int type)
BOOL object_completed (trans_obj_t *to)
BOOL block_ready_to_decode (trans_block_t *tb)


Detailed Description

ALC level receiving.

Author
peltotal
Date
2007/02/28 08:58:00
Revision
1.146

MAD-ALCLIB: Implementation of ALC/LCT protocols, Compact No-Code FEC, Simple XOR FEC, Reed-Solomon FEC, and RLC Congestion Control protocol. Copyright (c) 2003-2007 TUT - Tampere University of Technology main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi

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

In addition, as a special exception, TUT - Tampere University of Technology gives permission to link the code of this program with the OpenSSL library (or with modified versions of OpenSSL that use the same license as OpenSSL), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than OpenSSL. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.

Definition in file alc_rx.c.


Function Documentation

char* alc_recv ( int  s_id,
unsigned long long  toi,
unsigned long long *  data_len,
int *  retval 
)

This function gives an object to application, when it is completely received.

Parameters:
s_id session identifier
toi transport object identifier (identifies an object which is wanted to receive)
data_len stores the object length
retval stores return value in error cases/stopping situations
Returns:
pointer to buffer which contains object's data, NULL in error cases/stopping situations

Definition at line 1337 of file alc_rx.c.

References COM_NO_C_FEC_ENC_ID, FALSE, trans_obj::fec_enc_id, trans_obj::fec_inst_id, free_object(), get_alc_session(), trans_obj::next, null_fec_decode_object(), alc_session::obj_list, object_completed(), object_exist(), REED_SOL_FEC_INST_ID, remove_wanted_object(), rs_fec_decode_object(), RS_FEC_ENC_ID, SB_SYS_FEC_ENC_ID, SClosed, SExiting, SIMPLE_XOR_FEC_ENC_ID, alc_session::state, STxStopped, trans_obj::toi, and xor_fec_decode_object().

Referenced by recvfile().

Here is the call graph for this function:

Here is the caller graph for this function:

char* alc_recv2 ( int  s_id,
unsigned long long *  toi,
unsigned long long *  data_len,
int *  retval 
)

This function gives any object to application, when it is completely received.

Parameters:
s_id session identifier
toi stores transport object identifier
data_len stores the object length
retval stores return value in error cases/stopping situations
Returns:
pointer to buffer which contains object's data, NULL in error cases/stopping situations

Definition at line 1423 of file alc_rx.c.

References COM_NO_C_FEC_ENC_ID, FALSE, trans_obj::fec_enc_id, trans_obj::fec_inst_id, free_object(), get_alc_session(), trans_obj::next, null_fec_decode_object(), alc_session::obj_list, object_completed(), object_exist(), REED_SOL_FEC_INST_ID, remove_wanted_object(), rs_fec_decode_object(), RS_FEC_ENC_ID, SB_SYS_FEC_ENC_ID, SClosed, SExiting, SIMPLE_XOR_FEC_ENC_ID, alc_session::state, STxStopped, trans_obj::toi, and xor_fec_decode_object().

Referenced by fdtbasedrecv().

Here is the call graph for this function:

Here is the caller graph for this function:

char* alc_recv3 ( int  s_id,
unsigned long long *  toi,
int *  retval 
)

This function gives temporary filename of an object to the application, when object is completely received.

Parameters:
s_id session identifier
toi stores transport object identifier
retval stores return value in error cases/stopping situations
Returns:
pointer to buffer which contains temporary filename, NULL in error cases/stopping situations

Definition at line 1533 of file alc_rx.c.

References FALSE, free_object(), get_alc_session(), trans_obj::next, alc_session::obj_list, object_completed(), remove_wanted_object(), SClosed, SExiting, alc_session::state, STxStopped, trans_obj::tmp_filename, and trans_obj::toi.

Referenced by fdtbasedrecv(), and recvfile().

Here is the call graph for this function:

Here is the caller graph for this function:

int analyze_packet ( char *  data,
int  len,
alc_channel_t ch 
)

This is a private function which parses and analyzes an ALC packet.

Parameters:
data pointer to the ALC packet
len length of packet
ch pointer to the channel
Returns:
status of packet [WAITING_FDT = 5, OK = 4, EMPTY_PACKET = 3, HDR_ERROR = 2, MEM_ERROR = 1, DUP_PACKET = 0]

Definition at line 80 of file alc_rx.c.

References blocking_struct::A_large, blocking_struct::A_small, ALC_VERSION, alc_session::base_dir, trans_obj::block_list, block_ready_to_decode(), trans_obj::bs, alc_session::cc_id, COM_FEC_ENC_ID, COM_NO_C_FEC_ENC_ID, compute_blocking_structure(), trans_obj::content_enc_algo, wanted_obj::content_enc_algo, create_object(), create_units(), trans_unit::data, DUP_PACKET, EMPTY_PACKET, trans_obj::es_len, wanted_obj::es_len, trans_unit::esi, EXT_AUTH, EXT_CENC, EXT_FDT, EXT_FTI, EXT_NOP, EXT_TIME, trans_obj::fd, trans_obj::fd_st, FDT_TOI, trans_obj::fec_enc_id, wanted_obj::fec_enc_id, trans_obj::fec_inst_id, wanted_obj::fec_inst_id, wanted_obj::finite_field, FLUTE_VERSION, free_units(), free_units2(), get_wanted_object(), GZ_SUFFIX, GZIP, HDR_ERROR, blocking_struct::I, insert_object(), insert_unit(), is_received_instance(), trans_block::k, trans_obj::last_print_rx_percent, trans_obj::len, trans_unit::len, mad_rlc_analyze_cci(), trans_block::max_k, trans_block::max_n, wanted_obj::max_nb_of_es, MAX_PATH_LENGTH, trans_obj::max_sb_len, wanted_obj::max_sb_len, MEM_ERROR, blocking_struct::N, alc_session::nb_channel, wanted_obj::nb_of_es_per_group, trans_obj::nb_of_ready_blocks, trans_block::nb_of_rx_units, trans_unit::next, null_fec_decode_src_block(), object_exist(), trans_unit::offset, OK, PAD, PAD_SUFFIX, REED_SOL_FEC_INST_ID, retrieve_unit(), RLC, rs_fec_decode_src_block(), RS_FEC_ENC_ID, trans_obj::rx_bytes, alc_session::rx_fdt_instance_list, alc_session::rx_memory_mode, alc_channel::s, alc_session::s_id, SAFlagReceived, SB_LB_E_FEC_ENC_ID, SB_SYS_FEC_ENC_ID, trans_block::sbn, set_session_state(), SExiting, SIMPLE_XOR_FEC_ENC_ID, alc_session::state, trans_obj::tmp_filename, trans_obj::tmp_st_filename, trans_obj::toi, toi, wanted_obj::transfer_len, TRUE, alc_session::tsi, trans_block::unit_list, USE_RETRIEVE_UNIT, trans_unit::used, alc_session::verbosity, WAITING_FDT, alc_session::waiting_fdt_instance, xor_fec_decode_src_block(), and ZLIB.

Here is the call graph for this function:

BOOL block_ready_to_decode ( trans_block_t tb  ) 

This function checks if the block is ready for decoding.

Parameters:
tb pointer to the block
Returns:
TRUE when block is ready for decoding, FALSE otherwise

Definition at line 1772 of file alc_rx.c.

References FALSE, trans_block::k, trans_block::nb_of_rx_units, and TRUE.

Referenced by analyze_packet(), build_report(), and http_file_repair().

Here is the caller graph for this function:

char* fdt_recv ( int  s_id,
unsigned long long *  data_len,
int *  retval,
unsigned char *  content_enc_algo,
int *  fdt_instance_id 
)

This function gives an FDT Instance to application, when it is completely received.

Parameters:
s_id session identifier
data_len stores FDT instance length
retval stores return value in error cases/stopping situations
content_enc_algo stores used content encoding
fdt_instance_id stores FDT instance id
Returns:
pointer to buffer which contains FDT Instance's data, NULL in error cases/stopping situations

Definition at line 1653 of file alc_rx.c.

References COM_NO_C_FEC_ENC_ID, trans_obj::content_enc_algo, alc_session::fdt_list, trans_obj::fec_enc_id, trans_obj::fec_inst_id, free_object(), get_alc_session(), trans_obj::next, null_fec_decode_object(), object_completed(), REED_SOL_FEC_INST_ID, rs_fec_decode_object(), RS_FEC_ENC_ID, SB_SYS_FEC_ENC_ID, SClosed, set_received_instance(), SExiting, SIMPLE_XOR_FEC_ENC_ID, alc_session::state, STxStopped, trans_obj::toi, and xor_fec_decode_object().

Referenced by fdt_thread(), and recvfile().

Here is the call graph for this function:

Here is the caller graph for this function:

void join_rx_socket_thread ( alc_channel_t ch  ) 

This function waits until channel's rx_socket_thread is completed.

Parameters:
ch pointer to the channel

Definition at line 1287 of file alc_rx.c.

References alc_channel::handle_rx_socket_thread, and alc_channel::rx_socket_thread_id.

Referenced by close_alc_channel().

Here is the caller graph for this function:

BOOL object_completed ( trans_obj_t to  ) 

This function checks if the object has been received completely.

Parameters:
to pointer to the transport object
Returns:
TRUE when object is received completely, FALSE otherwise

Definition at line 1761 of file alc_rx.c.

References trans_obj::bs, FALSE, blocking_struct::N, trans_obj::nb_of_ready_blocks, and TRUE.

Referenced by alc_recv(), alc_recv2(), alc_recv3(), build_report(), and fdt_recv().

Here is the caller graph for this function:

trans_obj_t* object_exist ( unsigned long long  toi,
alc_session_t s,
int  type 
)

This function checks if a received unit belongs to an object which already exists in the session or not.

Parameters:
toi transport object identifier
s pointer to the session
type of object to be checked (0 = FDT Instance, 1 = normal object)
Returns:
pointer to the object in success, NULL otherwise

Definition at line 1734 of file alc_rx.c.

References alc_session::fdt_list, trans_obj::next, alc_session::obj_list, and trans_obj::toi.

Referenced by alc_recv(), alc_recv2(), analyze_packet(), and print_receiver_info().

Here is the caller graph for this function:

int recv_packet ( alc_session_t s  ) 

This is a private function which receives unit(s) from the session's channels.

Parameters:
s pointer to the session
Returns:
number of correct packets received from ALC session, or 0 when state is SClosed or no packets, or -1 in error cases, or -2 when state is SExiting

Definition at line 1049 of file alc_rx.c.

References alc_session::ch_list, is_empty(), MAX_PACKET_LENGTH, alc_session::nb_channel, and alc_channel::receiving_list.

Referenced by rx_thread().

Here is the call graph for this function:

Here is the caller graph for this function:

void* rx_socket_thread ( void *  ch  ) 

This function receives packets from the socket and stores them on the list.

Parameters:
ch pointer to the channel

Definition at line 1206 of file alc_rx.c.

References alc_session::addr_family, alc_rcv_container::from, alc_rcv_container::fromlen, MAX_PACKET_LENGTH, push_back(), alc_channel::receiving_list, alc_rcv_container::recvbuf, alc_rcv_container::recvlen, alc_channel::rx_sock, alc_channel::s, SActive, alc_session::src_addr, alc_session::state, and alc_session::verbosity.

Referenced by open_alc_channel().

Here is the call graph for this function:

Here is the caller graph for this function:

void* rx_thread ( void *  s  ) 

This function receives packets from the all channels in the session.

Parameters:
s pointer to the session

Definition at line 1305 of file alc_rx.c.

References alc_session::nb_channel, recv_packet(), SActive, SAFlagReceived, and alc_session::state.

Referenced by open_alc_session().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Fri Mar 9 20:08:54 2007 for MAD-FCL by  doxygen 1.5.0