From 618cd6cfb22df73bb97c65e5095dd1c4fecc26ce Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 23 Jun 2015 15:52:52 +0000 Subject: [PATCH] Move some structs from global_structures.h to timing.h --- global_structures.h | 58 ------------------------------------ osscan2.h | 1 + scan_engine.h | 2 ++ timing.h | 72 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 73 insertions(+), 60 deletions(-) diff --git a/global_structures.h b/global_structures.h index 5e6b1acb3..fd1c18bf3 100644 --- a/global_structures.h +++ b/global_structures.h @@ -235,64 +235,6 @@ struct FingerPrintDB { ~FingerPrintDB(); }; -/* Based on TCP congestion control techniques from RFC2581. */ -struct ultra_timing_vals { - double cwnd; /* Congestion window - in probes */ - int ssthresh; /* The threshold above which mode is changed from slow start - to congestion avoidance */ - /* The number of replies we would expect if every probe produced a reply. This - is almost like the total number of probes sent but it is not incremented - until a reply is received or a probe times out. This and - num_replies_received are used to scale congestion window increments. */ - int num_replies_expected; - /* The number of replies we've received to probes of any type. */ - int num_replies_received; - /* Number of updates to this timing structure (generally packet receipts). */ - int num_updates; - /* Last time values were adjusted for a drop (you usually only want - to adjust again based on probes sent after that adjustment so a - sudden batch of drops doesn't destroy timing. Init to now */ - struct timeval last_drop; - - double cc_scale(const struct scan_performance_vars *perf); - void ack(const struct scan_performance_vars *perf, double scale = 1.0); - void drop(unsigned in_flight, - const struct scan_performance_vars *perf, const struct timeval *now); - void drop_group(unsigned in_flight, - const struct scan_performance_vars *perf, const struct timeval *now); -}; - -/* These are mainly initializers for ultra_timing_vals. */ -struct scan_performance_vars { - int low_cwnd; /* The lowest cwnd (congestion window) allowed */ - int host_initial_cwnd; /* Initial congestion window for ind. hosts */ - int group_initial_cwnd; /* Initial congestion window for all hosts as a group */ - int max_cwnd; /* I should never have more than this many probes - outstanding */ - int slow_incr; /* How many probes are incremented for each response - in slow start mode */ - int ca_incr; /* How many probes are incremented per (roughly) rtt in - congestion avoidance mode */ - int cc_scale_max; /* The maximum scaling factor for congestion window - increments. */ - int initial_ssthresh; - double group_drop_cwnd_divisor; /* all-host group cwnd divided by this - value if any packet drop occurs */ - double group_drop_ssthresh_divisor; /* used to drop the group ssthresh when - any drop occurs */ - double host_drop_ssthresh_divisor; /* used to drop the host ssthresh when - any drop occurs */ - - /* Do initialization after the global NmapOps table has been filled in. */ - void init(); -}; - -struct timeout_info { - int srtt; /* Smoothed rtt estimate (microseconds) */ - int rttvar; /* Rout trip time variance */ - int timeout; /* Current timeout threshold (microseconds) */ -}; - struct seq_info { int responses; int ts_seqclass; /* TS_SEQ_* defines in nmap.h */ diff --git a/osscan2.h b/osscan2.h index 818502781..f48866b8f 100644 --- a/osscan2.h +++ b/osscan2.h @@ -130,6 +130,7 @@ #include "nbase.h" #include #include +#include "timing.h" #include "Target.h" class Target; diff --git a/scan_engine.h b/scan_engine.h index 140d51034..21fa90516 100644 --- a/scan_engine.h +++ b/scan_engine.h @@ -127,6 +127,8 @@ #ifndef SCAN_ENGINE_H #define SCAN_ENGINE_H +#include "nmap.h" /* stype */ + #include "timing.h" #include "tcpip.h" #include diff --git a/timing.h b/timing.h index df76060b9..d6be03829 100644 --- a/timing.h +++ b/timing.h @@ -128,8 +128,76 @@ #ifndef NMAP_TIMING_H #define NMAP_TIMING_H -#include "nmap.h" -#include "global_structures.h" +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#include /* u32 */ + +/* Based on TCP congestion control techniques from RFC2581. */ +struct ultra_timing_vals { + double cwnd; /* Congestion window - in probes */ + int ssthresh; /* The threshold above which mode is changed from slow start + to congestion avoidance */ + /* The number of replies we would expect if every probe produced a reply. This + is almost like the total number of probes sent but it is not incremented + until a reply is received or a probe times out. This and + num_replies_received are used to scale congestion window increments. */ + int num_replies_expected; + /* The number of replies we've received to probes of any type. */ + int num_replies_received; + /* Number of updates to this timing structure (generally packet receipts). */ + int num_updates; + /* Last time values were adjusted for a drop (you usually only want + to adjust again based on probes sent after that adjustment so a + sudden batch of drops doesn't destroy timing. Init to now */ + struct timeval last_drop; + + double cc_scale(const struct scan_performance_vars *perf); + void ack(const struct scan_performance_vars *perf, double scale = 1.0); + void drop(unsigned in_flight, + const struct scan_performance_vars *perf, const struct timeval *now); + void drop_group(unsigned in_flight, + const struct scan_performance_vars *perf, const struct timeval *now); +}; + +/* These are mainly initializers for ultra_timing_vals. */ +struct scan_performance_vars { + int low_cwnd; /* The lowest cwnd (congestion window) allowed */ + int host_initial_cwnd; /* Initial congestion window for ind. hosts */ + int group_initial_cwnd; /* Initial congestion window for all hosts as a group */ + int max_cwnd; /* I should never have more than this many probes + outstanding */ + int slow_incr; /* How many probes are incremented for each response + in slow start mode */ + int ca_incr; /* How many probes are incremented per (roughly) rtt in + congestion avoidance mode */ + int cc_scale_max; /* The maximum scaling factor for congestion window + increments. */ + int initial_ssthresh; + double group_drop_cwnd_divisor; /* all-host group cwnd divided by this + value if any packet drop occurs */ + double group_drop_ssthresh_divisor; /* used to drop the group ssthresh when + any drop occurs */ + double host_drop_ssthresh_divisor; /* used to drop the host ssthresh when + any drop occurs */ + + /* Do initialization after the global NmapOps table has been filled in. */ + void init(); +}; + +struct timeout_info { + int srtt; /* Smoothed rtt estimate (microseconds) */ + int rttvar; /* Rout trip time variance */ + int timeout; /* Current timeout threshold (microseconds) */ +}; /* Call this function on a newly allocated struct timeout_info to initialize the values appropriately */