             if peer.state != .connected || peer.socket == nil {
                 return
             }
-            if peer.keepaliveTimer?.isValid == true && abs(peer.lastReceivedOrSentData.timeIntervalSinceNow) < 5.0 {
-                // flood protection
+
+            peer.lastReceivedData = Date.init()
+
+            if peer.keepaliveTimer?.isValid == true {
                 return
             }
-            peer.lastReceivedOrSentData = Date.init()
-
-            let delay: TimeInterval = Timeouts.header.rawValue - 5.0 - (Double(arc4random_uniform(10000)) / Double(1000)) // definitely 5s before HEADER timeout, or as much as 15s before
-            if peer.keepaliveTimer?.isValid == true {
-                NSLog("BluepeerObject: keepalive rescheduled for \(peer.displayName) in \(delay)s")
-                peer.keepaliveTimer?.fireDate = Date.init(timeIntervalSinceNow: delay)
-            } else {
-                NSLog("BluepeerObject: keepalive INITIAL SCHEDULING for \(peer.displayName) in \(delay)s")
-                peer.keepaliveTimer = Timer.scheduledTimer(timeInterval: delay, target: self, selector: #selector(self.keepAliveTimerFired), userInfo: ["peer":peer], repeats: true)
-            }
+
+            let delay: TimeInterval = Timeouts.keepAlive.rawValue - 5 - (Double(arc4random_uniform(5000)) / Double(1000)) // keepAlive.rawValue - 5 - (up to 5)
+            NSLog("BluepeerObject: keepalive INITIAL SCHEDULING for \(peer.displayName) in \(delay)s")
+            peer.keepaliveTimer = Timer.scheduledTimer(timeInterval: delay, target: self, selector: #selector(self.keepAliveTimerFired), userInfo: ["peer":peer], repeats: true)
         })
     }
     

    var dnsService: HHService?
    var announced = false
    open var keepaliveTimer: Timer?
    open var lastReceivedOrSentData: Date = Date.init(timeIntervalSince1970: 0)
}

@objc public protocol BluepeerSessionManagerDelegate {

            var senddata = NSData.init(data: self.keepAliveHeader) as Data
            senddata.append(self.headerTerminator)
            self.logDelegate?.didReadWrite("writeKeepAlive")
            
//            NSLog("keepAlivetimer writes: \(senddata.hex)")
            
            peer.socket?.write(senddata, withTimeout: Timeouts.header.rawValue, tag: DataTag.tag_WRITING.rawValue)
            NSLog("BluepeerObject: send keepAlive to \(peer.displayName) @ \(peer.socket?.connectedHost)")
        }
