00001
00002
00003 #ifndef ns_worm_h
00004 #define ns_worm_h
00005
00006 #include "timer-handler.h"
00007 #include "app.h"
00008
00009 class WormApp;
00010
00011
00012 class ProbingTimer : public TimerHandler {
00013 public:
00014 ProbingTimer(WormApp* t) : TimerHandler(), t_(t) {};
00015 inline virtual void expire(Event*);
00016 protected:
00017 WormApp* t_;
00018 };
00019
00020
00021 class WormApp : public Application {
00022 public:
00023 WormApp();
00024
00025
00026 virtual void timeout();
00027
00028 void process_data(int, AppData*);
00029
00030 virtual int command(int argc, const char*const* argv);
00031
00032 protected:
00033
00034 virtual void recv(int nbytes);
00035
00036
00037 unsigned long my_addr_;
00038
00039
00040 static double total_addr_;
00041
00042 static int first_probe_;
00043
00044
00045 double scan_rate_;
00046 int scan_port_;
00047 int p_size_;
00048 };
00049
00050
00051 class DnhWormApp : public WormApp {
00052 public:
00053 DnhWormApp();
00054
00055
00056 void timeout();
00057
00058 int command(int argc, const char*const* argv);
00059
00060 protected:
00061 void recv(int nbytes);
00062
00063 void send_probe();
00064 void probe();
00065
00066 bool infected_;
00067 static unsigned long infect_total_;
00068
00069 ProbingTimer *timer_;
00070
00071
00072 double p_inv_;
00073
00074
00075 static unsigned long addr_low_, addr_high_;
00076
00077
00078 static float local_p_;
00079
00080
00081 static unsigned long default_gw_;
00082 };
00083
00084
00085 class AnWormApp : public WormApp {
00086 public:
00087 AnWormApp();
00088
00089
00090 void timeout();
00091
00092 int command(int argc, const char*const* argv);
00093
00094 protected:
00095 void start();
00096 void update();
00097
00098 void recv(int nbytes);
00099
00100 void probe(int);
00101
00102 ProbingTimer *timer_;
00103
00104 int time_step_;
00105
00106
00107 unsigned long addr_low_, addr_high_;
00108 unsigned long dn_low_, dn_high_;
00109
00110
00111 double s_, i_, r_, s_max_, n_;
00112 double v_percentage_;
00113 double beta_, gamma_;
00114
00115
00116 double probe_in, probe_recv;
00117 double probe_out;
00118 };
00119
00120
00121 #endif