00001 /* 00002 * Copyright 2005, 2006, Internet2 00003 * Legal conditions are in file LICENSE 00004 * (MD5 = c434f2e53b8089d8b4d0172c7ce07360). 00005 */ 00006 /** 00007 * 00008 * @file vfer_func_rel.c 00009 * @author Ivan Beschastnikh 00010 * @brief Implements functions controlling reliability in VFER 00011 * 00012 * This file implements the boolean functions that are used to 00013 * determine whether a frame should be kept around (retransmitted) or 00014 * dropped. 00015 * 00016 * - 08/21/05 ivan created 00017 */ 00018 00019 #include "vfer_func_rel.h" 00020 00021 /** 00022 * @param frag_size fragment size 00023 * @param dim1 number of rows in int matrix mat 00024 * @param dim2 number of columns in int matrix mat 00025 * @param mat matrix of negative acknowledgement vectors so far for this frame 00026 * @return 00027 * -1 on error 00028 * 1 if the frame should be "kept" 00029 * 0 if the frame should be dropped 00030 */ 00031 //inline bool_t fun_ratio(context_t* context) { //int frag_size, int dim1, int dim2, int** mat) { 00032 inline bool_t rf_frag_ratio(int frag_size, int dim1, int dim2, int** mat) { 00033 static int timestep_mark = 0; 00034 int t = dim1 - 1; 00035 int j, sum1, sum2; 00036 00037 if (dim1 < 2) return -1; 00038 00039 /* determine if we have reached a threshold where we have too 00040 * small a number of missing fragments, thus need to apply a 00041 * diff test for this and following timesteps */ 00042 sum1 = 0; 00043 for (j = 0; j < dim2; j++) 00044 sum1 += mat[t][j]; 00045 if (sum1 < fratio_M) { timestep_mark = dim1; } 00046 00047 /* run test2 */ 00048 if (timestep_mark != 0) { 00049 /* determine if we made too many retransmission attempts */ 00050 if (dim1 - timestep_mark < fratio_R) return 1; 00051 return 0; 00052 } 00053 00054 /* run test1: compute the ratio of bytes transferred for this 00055 * timestep to the number of bytes requested (in the missing 00056 * fragments for previous neg vec ack)*/ 00057 sum1 = sum2 = 0; 00058 for (j = 0; j < dim2; j++) { 00059 sum1 += mat[t][j] * frag_size; 00060 sum2 += mat[t-1][j] * frag_size; 00061 } 00062 if (((sum1 * 1.0) / sum2) <= fratio_C) 00063 return 0; 00064 return 1; 00065 } /* rf_frag_ratio() */ 00066 00067 /** 00068 * Full reliability function that never gives up on a datagram 00069 * @param c context 00070 * @return 1 always 00071 */ 00072 bool_t rf_always_reliable(context_t* c) { 00073 // printf("eval in rf_always reliable\n"); 00074 return 1; 00075 } 00076 /* rf_always_reliable() */ 00077 00078 00079 /* insert other reliability functions here */