00001 // Copyright (c) 2000 by the University of Southern California 00002 // All rights reserved. 00003 // 00004 // Permission to use, copy, modify, and distribute this software and its 00005 // documentation in source and binary forms for non-commercial purposes 00006 // and without fee is hereby granted, provided that the above copyright 00007 // notice appear in all copies and that both the copyright notice and 00008 // this permission notice appear in supporting documentation. and that 00009 // any documentation, advertising materials, and other materials related 00010 // to such distribution and use acknowledge that the software was 00011 // developed by the University of Southern California, Information 00012 // Sciences Institute. The name of the University may not be used to 00013 // endorse or promote products derived from this software without 00014 // specific prior written permission. 00015 // 00016 // THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about 00017 // the suitability of this software for any purpose. THIS SOFTWARE IS 00018 // PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 00019 // INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 00020 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00021 // 00022 // Other copyrights might apply to parts of this software and are so 00023 // noted when applicable. 00024 // 00025 00026 /*****************************************************************/ 00027 /* diff_sink.h : Header file for sink agent */ 00028 /* By : Chalermek Intanagonwiwat (USC/ISI) */ 00029 /* Last Modified : 8/21/99 */ 00030 /*****************************************************************/ 00031 00032 00033 #ifndef ns_diff_sink_h 00034 #define ns_diff_sink_h 00035 00036 #include "agent.h" 00037 #include "tclcl.h" 00038 #include "packet.h" 00039 #include "ip.h" 00040 #include "diff_header.h" 00041 #include "diffusion.h" 00042 00043 00044 class SinkAgent; 00045 00046 // Timer for packet rate 00047 00048 class Sink_Timer : public TimerHandler { 00049 public: 00050 Sink_Timer(SinkAgent *a) : TimerHandler() { a_ = a; } 00051 protected: 00052 virtual void expire(Event *e); 00053 SinkAgent *a_; 00054 }; 00055 00056 00057 // For periodic report of avg and var pkt received. 00058 00059 class Report_Timer : public TimerHandler { 00060 public: 00061 Report_Timer(SinkAgent *a) : TimerHandler() { a_ = a; } 00062 protected: 00063 virtual void expire(Event *e); 00064 SinkAgent *a_; 00065 }; 00066 00067 00068 // Timer for periodic interest 00069 00070 class Periodic_Timer : public TimerHandler { 00071 public: 00072 Periodic_Timer(SinkAgent *a) : TimerHandler() { a_ = a; } 00073 protected: 00074 virtual void expire(Event *e); 00075 SinkAgent *a_; 00076 }; 00077 00078 00079 // Class SinkAgent as source and sink for directed diffusion 00080 00081 class SinkAgent : public Agent { 00082 00083 public: 00084 SinkAgent(); 00085 int command(int argc, const char*const* argv); 00086 virtual void timeout(int); 00087 00088 void report(); 00089 void recv(Packet*, Handler*); 00090 void reset(); 00091 void set_addr(ns_addr_t); 00092 int get_pk_count(); 00093 void incr_pk_count(); 00094 Packet *create_packet(); 00095 00096 protected: 00097 bool APP_DUP_; 00098 00099 bool periodic_; 00100 bool always_max_rate_; 00101 int pk_count; 00102 unsigned int data_type_; 00103 int num_recv; 00104 int num_send; 00105 int RecvPerSec; 00106 00107 double cum_delay; 00108 double last_arrival_time; 00109 00110 Data_Hash_Table DataTable; 00111 00112 void Terminate(); 00113 void bcast_interest(); 00114 void data_ready(); 00115 void start(); 00116 void stop(); 00117 virtual void sendpkt(); 00118 00119 int running_; 00120 int random_; 00121 int maxpkts_; 00122 double interval_; 00123 00124 int simple_report_rate; 00125 int data_counter; 00126 00127 Sink_Timer sink_timer_; 00128 Periodic_Timer periodic_timer_; 00129 Report_Timer report_timer_; 00130 00131 friend class Periodic_Timer; 00132 }; 00133 00134 00135 #endif 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146
1.3.3