to avoid going down in congested line scenario, also need longer ping timeout
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 26 May 2015 16:19:33 +0000 (18:19 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 26 May 2015 16:19:33 +0000 (18:19 +0200)
also bugfix in HostStatus

src/host/hoststatus.cpp
src/host/pingscheduler.cpp
src/host/pingscheduler.h
src/main.cpp

index 2e1db87..42e5cc7 100644 (file)
@@ -227,7 +227,11 @@ void HostStatus::analyze_ping_statistics()
     // However, if all pings timed out even in burst mode, then we still declare
     // the line down
     if (InBurstMode && PingCongestionCount >= PingsPerformedCount)
+    {
+        GlobalLogger.notice() << log_prefix() << "All pings timed out despite "
+            << "using more pings per IP --> assume connection is really down";
         ExceededPingFailedLimit = true;
+    }
 
     // notify if the amount of pings that failed exceed the limit
     if ( exceeded_ping_failed_limit() )
index 72b084e..b272379 100644 (file)
@@ -44,6 +44,7 @@ using boost::posix_time::milliseconds;
 using boost::shared_ptr;
 using I2n::Logger::GlobalLogger;
 
+
 //-----------------------------------------------------------------------------
 // PingScheduler
 //-----------------------------------------------------------------------------
@@ -81,7 +82,8 @@ PingScheduler::PingScheduler(
         LinkStatusItem link_analyzer,
         const int first_delay,
         const int n_parallel_pings,
-        const int parallel_ping_delay
+        const int parallel_ping_delay,
+        const int ping_timeout_factor
 ) :
     IoService( io_serv ),
     NetworkInterfaceName( network_interface ),
@@ -95,6 +97,7 @@ PingScheduler::PingScheduler(
     NextPingTimer( *io_serv ),
     TimeSentLastPing( microsec_clock::universal_time() ),
     PingReplyTimeout( ping_reply_timeout ),
+    PingReplyTimeoutOrig( ping_reply_timeout ),
     HostAnalyzer( destination_address, ping_fail_percentage_limit,
                   ping_congestion_percentage_limit,
                   ping_congestion_duration_thresh, n_parallel_pings,
@@ -106,7 +109,8 @@ PingScheduler::PingScheduler(
     DelayedPingTimer( *io_serv ),
     WantToPing( false ),
     LogPrefix(),
-    ContinueOnOutdatedIps( false )
+    ContinueOnOutdatedIps( false ),
+    PingTimeoutFactor( ping_timeout_factor )
 {
     BOOST_ASSERT( !network_interface.empty() );
     BOOST_ASSERT( !destination_address.empty() );
@@ -378,6 +382,9 @@ void PingScheduler::update_ping_interval()
 
         GlobalLogger.debug() << LogPrefix << "- Speeding up ping interval to: "
                              << PingIntervalInSec << "s";
+        PingReplyTimeout = PingReplyTimeoutOrig * PingTimeoutFactor;
+        GlobalLogger.debug() << LogPrefix << "- Increase ping timeout to "
+                             << PingReplyTimeout << "s";
     }
     else
     {
@@ -385,6 +392,9 @@ void PingScheduler::update_ping_interval()
 
         GlobalLogger.debug() << LogPrefix << "- Stick to the original ping "
                              << "interval: " << PingIntervalInSec << "s";
+        PingReplyTimeout = PingReplyTimeoutOrig;
+        GlobalLogger.debug() << LogPrefix << "- Reset ping timeout to "
+                             << PingReplyTimeout << "s";
     }
 }
 
index 2916058..91da6e6 100644 (file)
@@ -65,7 +65,8 @@ public:
             LinkStatusItem link_analyzer,
             const int first_delay,
             const int n_parallel_pings,
-            const int parallel_ping_delay
+            const int parallel_ping_delay,
+            const int ping_timeout_factor
     );
     ~PingScheduler();
 
@@ -129,7 +130,9 @@ private:
     /// Keeps track of the time when the last ping was send
     boost::posix_time::ptime TimeSentLastPing;
     /// time threshold for ping
-    const int PingReplyTimeout;
+    int PingReplyTimeout;
+    /// time threshold for ping -- original value
+    const int PingReplyTimeoutOrig;
     /// Object responsible to evaluate the status of the host
     HostStatus HostAnalyzer;
     /// The Dns resolver
@@ -148,6 +151,7 @@ private:
     std::string LogPrefix;
     /// Flag whether DNS resolution has failed so we have to run on outdated IPs
     bool ContinueOnOutdatedIps;
+    int PingTimeoutFactor;
 };
 
 //-----------------------------------------------------------------------------
index 597b143..5ad6319 100644 (file)
@@ -283,6 +283,7 @@ bool init_pingers(
         int parallel_ping_delay = 100;   // ms
         int congestion_duration_thresh = 10; // seconds
         int congestion_percentage_thresh = 75;
+        int ping_timeout_factor = 3;
 
         PingSchedulerItem scheduler(
                 new PingScheduler(
@@ -299,7 +300,8 @@ bool init_pingers(
                         status_notifier,
                         current_delay,
                         n_parallel_pings,
-                        parallel_ping_delay
+                        parallel_ping_delay,
+                        ping_timeout_factor
                 )
         );
         scheduler_list->push_back( scheduler );