commit 9a1799ba1c17cb3c95cdfb4aaee3ccb9c296d46e
parent c7c6ca3957f922d66d01fa50c99a05828296b9ba
Author: Remy Noulin <loader2x@gmail.com>
Date: Sat, 8 Jul 2023 06:53:39 +0200
detect when packets are coming too fast
heartbeat.c | 9 +++++++++
1 file changed, 9 insertions(+)
Diffstat:
1 file changed, 9 insertions(+), 0 deletions(-)
diff --git a/heartbeat.c b/heartbeat.c
@@ -657,6 +657,15 @@ void probe(char *cfgfile) {
// update state for this agent
cleanFinishSmallDictP(agent) = getG(completeCfg, rtSmallDictt, agents[m->id]);
+ /* TODO use specific period for agent */
+ u64 expectedNextTime = getG(agent, rtU64, "mono") + (u64)period * 1000000000UL;
+ time = getMonotonicTime();
+ u64 elapsed = time - expectedNextTime;
+ if (elapsed < (u64)period * 8000000000UL) {
+ char *ip = inet_ntoa((client).sin_addr);
+ logE("Packet from %s with ip %s came too early.", agents[m->id], ip);
+ }
+ setG(agent, "mono", time);
setG(agent, "time", getCurrentUnixTime());
char *newstate = m->messageId ? "alive" : "init";
if (!eqG($(agent, "state"), newstate)) {