• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/diffusion3/filters/rmst/rmst.hh

00001 //
00002 // rmst.hh         : Rmst Class
00003 // authors         : Fred Stann
00004 //
00005 // Include file for Reliable Multi-Segment Transport support defines and ADTs.
00006 //
00007 // Copyright (C) 2003 by the University of Southern California
00008 // $Id: rmst.hh,v 1.2 2005/09/13 04:53:48 tomh Exp $
00009 //
00010 // This program is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public License,
00012 // version 2, as published by the Free Software Foundation.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License along
00020 // with this program; if not, write to the Free Software Foundation, Inc.,
00021 // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00022 //
00023 // Linking this file statically or dynamically with other modules is making
00024 // a combined work based on this file.  Thus, the terms and conditions of
00025 // the GNU General Public License cover the whole combination.
00026 //
00027 // In addition, as a special exception, the copyright holders of this file
00028 // give you permission to combine this file with free software programs or
00029 // libraries that are released under the GNU LGPL and with code included in
00030 // the standard release of ns-2 under the Apache 2.0 license or under
00031 // otherwise-compatible licenses with advertising requirements (or modified
00032 // versions of such code, with unchanged license).  You may copy and
00033 // distribute such a system following the terms of the GNU GPL for this
00034 // file and the licenses of the other code concerned, provided that you
00035 // include the source code of that other code when and as the GNU GPL
00036 // requires distribution of source code.
00037 //
00038 // Note that people who make modified versions of this file are not
00039 // obligated to grant this special exception for their modified versions;
00040 // it is their choice whether to do so.  The GNU General Public License
00041 // gives permission to release a modified version without this exception;
00042 // this exception also makes it possible to release a modified version
00043 // which carries forward this exception.
00044 
00045 #ifndef RMST
00046 #define RMST
00047 
00048 #ifdef HAVE_CONFIG_H
00049 #include "config.h"
00050 #endif //HAVE_CONFIG_H
00051 
00052 #include <map>
00053 #include "nr/nr.hh"
00054 #include "main/tools.hh"
00055 typedef long handle;
00056 
00057 // This dictates how much actual data goes into a packet. Because mote-nic
00058 // will currently only allow 200 byte packets, it is pretty low.
00059 #define MAX_FRAG_SIZE 50
00060 
00061 typedef map<int, void*, less<int> > Int2Frag;
00062 
00063 class NakData {
00064 public:
00065   NakData(){nak_sent_ = false; send_nak_ = false;}
00066   struct timeval tmv;
00067   bool nak_sent_;
00068   bool send_nak_;
00069 };
00070 
00071 typedef map<int, NakData*, less<int> > Int2Nak;
00072 
00073 class Rmst {
00074 public:
00075   Rmst(int id, int mx_frag = -1);
00076   ~Rmst();
00077   void* getFrag(int frag_no);
00078   void putFrag(int frag_no, void *data);
00079   bool holeInFragMap();
00080   bool rmstComplete();
00081   bool inHoleMap(int hole_no);
00082   void putHole(int hole_no);
00083   NakData* getHole(int hole_no);
00084   void delHole(int hole_no);
00085   bool holeMapEmpty();
00086   void cleanHoleMap();
00087   void syncHoleMap();
00088   handle watchdog_handle_;
00089   bool watchdog_active_;
00090   bool cancel_watchdog_;
00091   handle ack_timer_handle_;
00092   bool ack_timer_active_;
00093   Int2Nak hole_map_;
00094   int rmst_no_;
00095   int max_frag_;
00096   int max_frag_len_;
00097   int max_frag_rec_;
00098   int max_frag_sent_;
00099   int sync_base_;
00100   int pkts_rec_;
00101   int pkts_sent_;
00102   int naks_rec_;
00103   int32_t last_hop_;
00104   int32_t fwd_hop_;
00105   int last_hop_pkts_sent_;
00106   bool local_source_;
00107   u_int16_t local_source_port_;
00108   char *target_str_;
00109   bool reinf_;
00110   bool acked_;
00111   bool resent_last_data_;
00112   bool resent_last_exp_;
00113   bool wait_for_new_path_;
00114   bool sent_exp_req_;
00115   struct timeval last_data_time_;
00116   struct timeval last_nak_time_;
00117   struct timeval exp_req_time_;
00118 private:
00119   Int2Frag frag_map_;
00120 };
00121 
00122 typedef map<int, Rmst*, less<int> > Int2Rmst;
00123 
00124 // Utility function
00125 void PrintTime(struct timeval *time);
00126 
00127 #endif // RMST

Generated on Tue Aug 10 2010 16:16:06 for ns-2.33 by  doxygen 1.7.1