main.c

Go to the documentation of this file.
00001 
00033 #include <signal.h>
00034 #include <stdio.h>
00035 
00036 #ifdef _MSC_VER
00037 #include <windows.h>
00038 #else
00039 #include <unistd.h>
00040 #endif
00041 
00042 #include "../flutelib/flute.h"
00043 #include "repair_sender.h"
00044 
00045 #define MAD_REPAIR_SENDER_VERSION "0.1" 
00047 int s_id; 
00056 void signal_handler(int sig){
00057   printf("\nExiting...\n\n");
00058   fflush(stdout);
00059   set_flute_session_state(s_id, SExiting);
00060 }
00061 
00067 void usage(void) {
00068   printf("\nRepair Sender Version %s, %s\n\n", MAD_REPAIR_SENDER_VERSION, MAD_FCL_RELEASE_DATE);
00069   printf("  Copyright (c) 2003-2007 TUT - Tampere University of Technology\n");
00070   printf("  main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi\n");
00071   printf("  web site: http://www.atm.tut.fi/mad\n\n");
00072   printf("  This is free software, and you are welcome to redistribute it\n");
00073   printf("  under certain conditions; See the GNU General Public License\n");
00074   printf("  as published by the Free Software Foundation, version 2 or later,\n");
00075   printf("  for more details.\n");  
00076   printf("  * mad_rlc.c & mad_rlc.h -- Portions of code derived from MCL library by\n");
00077   printf("  * Vincent Roca et al. (http://www.inrialpes.fr/planete/people/roca/mcl/)\n");
00078   printf("  *\n");
00079   printf("  * Copyright (c) 1999-2004 INRIA - Universite Paris 6 - All rights reserved\n");
00080   printf("  * (main author: Julien Laboure - julien.laboure@inrialpes.fr\n");
00081   printf("  *               Vincent Roca - vincent.roca@inrialpes.fr)\n");
00082   printf("  * fec.c & fec.h -- forward error correction based on Vandermonde matrices\n");
00083   printf("  * 980624\n");
00084   printf("  * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)\n");
00085   printf("  *\n");
00086   printf("  * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),\n");
00087   printf("  * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and\n");
00088   printf("  * Hari Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995\n");
00089   printf("  *\n");
00090   printf("  * Redistribution and use in source and binary forms, with or without\n");
00091   printf("  * modification, are permitted provided that the following conditions\n");
00092   printf("  * are met:\n");
00093   printf("  *\n");
00094   printf("  * 1. Redistributions of source code must retain the above copyright\n");
00095   printf("  *    notice, this list of conditions and the following disclaimer.\n");
00096   printf("  * 2. Redistributions in binary form must reproduce the above\n");
00097   printf("  *    copyright notice, this list of conditions and the following\n");
00098   printf("  *    disclaimer in the documentation and/or other materials\n");
00099   printf("  *    provided with the distribution.\n");
00100   printf("  *\n");
00101   printf("  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND\n");
00102   printf("  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n");
00103   printf("  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n");
00104   printf("  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS\n");
00105   printf("  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n");
00106   printf("  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n");
00107   printf("  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n");
00108   printf("  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n");
00109   printf("  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR\n");
00110   printf("  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n");
00111   printf("  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY\n");
00112   printf("  * OF SUCH DAMAGE.\n");
00113   printf("\nUsage: repair_sender [-m:str] [-p:int] [-i:str] [-c:int] [-t:ull] [-e:int]\n"); 
00114   printf("                     [-K:str] [-a:str] [-h] [[-n:int] | [-C]] [-f:str] [-r:int]\n");
00115   printf("                     [-v:int] [-D:ull] [-V:str] [-T:int] [-P:float,float]\n");
00116   printf("                     [-H] [-B:str]");
00117   printf(" [-d:str]");
00118   printf(" [-w:int]");
00119   printf("\n\n");
00120   printf("Options:\n\n");
00121   printf("   -m:str           IP4 or IP6 address for base channel,\n");
00122   printf("   -e:int           FEC-OTI for file objects\n");
00123   printf("                    [0 = FEC-OTI in FDT, 1 = FEC-OTI in EXT_FTI], default: 0\n");
00124   printf("                    default: %s or %s\n", DEF_MCAST_IPv4_ADDR, DEF_MCAST_IPv6_ADDR);
00125   printf("   -p:int           Port number for base channel, default: %s\n", DEF_MCAST_PORT);
00126   printf("   -i:str           Local interface to bind to, default: INADDR_ANY\n");
00127   printf("   -t:ull           TSI for this session, default: %i\n", DEF_TSI);
00128   printf("   -w:int           Congestion control scheme [0 = Null, 1 = RLC],\n");
00129   printf("                    default: %i; the number of channels, defined by -c option,\n", DEF_CC);
00130   printf("                    are used with both schemes and bitrate of each channel is\n");
00131   printf("                    set according to RLC rules\n");
00132   printf("   -a:str           Address family (IP4 or IP6), default: IP4\n");
00133   printf("   -v:int           Verbosity level, [0 = low, 1 = high] default: 1\n");
00134   printf("   -V:str           Print logs to 'str' file, default: print to stdout\n");
00135   printf("   -d:str           SDP file (start FLUTE session based on SDP file),\n");
00136   printf("                    default: no\n");
00137   printf("   -h               Print this help\n");
00138   printf("   -c:int           Number of used channels, default: %i\n", DEF_NB_CHANNEL);
00139   printf("   -D:ull           Duration of the session in seconds, default: %i\n", DEF_SESSION_DURATION);
00140   printf("   -f:str           FDT file of the FLUTE session to be repaired, default: no\n");
00141   printf("   -B:str           Base directory for files of the FLUTE session to be\n");
00142   printf("                    repaired, default: no\n");
00143   printf("   -K:str           Repair configuration file, default: %s\n", DEF_REPAIR_SENDER_CONF_FILE);
00144   printf("   -r:int           Transmission rate at base channel in kbits/s, default: %i\n", DEF_TX_RATE);
00145   printf("   -T:int           Time To Live or Hop Limit for this session, default: %i\n", DEF_TTL);
00146   printf("   -e:int           Use EXT_FTI extensions header for file objects\n");
00147   printf("                    [0 = no, 1 = yes], default: 1\n");
00148   printf("   -n:int           Number of transmissions, default: %i\n", DEF_TX_NB);
00149   printf("   -C               Continuous transmission, default: not used\n");
00150   printf("   -P[:float,float] Simulate packet losses, default: %.1f,%.1f\n", (float)P_LOSS_WHEN_OK,
00151          (float)P_LOSS_WHEN_LOSS);
00152   printf("   -H               Use Half-word (if used TSI field could be 16, 32 or 48\n");
00153   printf("                    bits long and TOI field could be 16, 32, 48 or 64 bits\n");
00154   printf("                    long), default: not used\n");
00155   exit(1);
00156 }
00157 
00168 int main(int argc, char **argv) {
00169 
00170   int retval = 0;
00171   arguments_t a;
00172     
00173   /* Set signal handler */
00174   
00175   signal(SIGINT, signal_handler);
00176 #ifdef _MSC_VER
00177   signal(SIGBREAK, signal_handler);
00178 #endif
00179   
00180   if(start_up_flute() != 0) {
00181         return -1;
00182   }
00183 
00184   retval = parse_args(argc, argv, &a);
00185   
00186   if(retval == -1) {
00187     usage();
00188   }
00189   
00190   s_id = -1; 
00191                 
00192   retval = repair_sender(&a, &s_id);
00193   
00194   if(s_id == -1) {    
00195         shut_down_flute(&a);
00196         return retval;
00197   }
00198   
00199   if(retval == -4) { /* bind failed */
00200         shut_down_flute(&a);
00201         return retval;  
00202   }
00203 
00204   shut_down_flute(&a);
00205   return retval;
00206 }

Generated on Fri Mar 9 19:59:52 2007 for MAD-FCL by  doxygen 1.5.0