技术跟踪和检测的一系列数据缺失(例如安全日志数据) [英] Technique to track and detect missing data in a series (e.g. Security Log data)

查看:132
本文介绍了技术跟踪和检测的一系列数据缺失(例如安全日志数据)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有给我发的数据与不断增加的折射率(n ++)数据流。它有可能为某些数据被发送乱序,丢失或以其他方式需要重发。

I have a datastream that sends me data with an ever-increasing index (n++). It is possible for some of that data to be sent out of order, lost or otherwise need to be retransmitted.

示例

  1. 假设我有一个由我的应用程序监视的安全日志文件。这是可能的坏家伙晚饭的几个条目preSS或prevent传输。我要警惕这一点。

  1. Assume I have a security log file that is monitored by my app. It is possible for a bad guy to suppress or prevent transmission of a few entries. I want to be alerted to this fact.

此外,假定这个数据可以被发送到日志记录器不按顺序

Also assume that this data may be sent to the log recorder out of order.

看来这个逻辑无处不在,我不想另起炉灶,做一些不到有效的。

It seems this logic is everywhere I don't want to reinvent the wheel and do something less than efficient.

问题

我应该如何实现(或者是参考实现存在的话),让我跟踪乱序数据,并可能包含在一个序列中丢失的数据?

How should I implement (or what reference implementation exists) that allows me to track data received out of order and may contain missing data in a sequence?

(你也标注在这个问题援助AP preciated)

(Also your assistance in tagging this question is appreciated)

推荐答案

使用链表好了,好了我这样做。这里的的是这个地方......无论哪种方式,这是优化的输入系列在性质上或多或少的增加,一个以前的工作

Okay, well I did this using a linked list. There has to be a prior work for this somewhere... either way, this is optimized for an input series that is more or less increasing in nature.

让,如果你看到任何错误我知道,或者改进我可以让

Let me know if you see any bugs, or enhancements I can make

    public class ContiguousDataValue
    {
        public int UpperInt { get; set; }
        public int LowerInt { get; set; }

        public override string ToString()
        {
            return "Upper" + UpperInt + " Lower" + LowerInt; 
        }
    }


public class ContiguousData 
{
    LinkedList<ContiguousDataValue> ranges = new LinkedList<ContiguousDataValue>();

    public void AddValue(int val)
    {
        for (LinkedListNode<ContiguousDataValue> range = ranges.Last; range != null; range = range.Previous)
        {
            if (val > range.Value.UpperInt)
            {
                // increment current node if applicable 
                if (val == range.Value.UpperInt + 1)
                    range.Value.UpperInt = val;
                else
                    ranges.AddAfter(range, new ContiguousDataValue() { UpperInt = val, LowerInt = val });
                return;
            }
            else if (val < range.Value.LowerInt)
            {
                if (val == range.Value.LowerInt - 1)
                {
                    range.Value.LowerInt = val;
                    return;
                }
                else
                {
                    continue;
                }
            }
        }
        // Anything that reaches this line is either a very new low value, or the first entry
        ranges.AddLast(new ContiguousDataValue() { UpperInt = val, LowerInt = val });
    }
 }

这篇关于技术跟踪和检测的一系列数据缺失(例如安全日志数据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆