Пример #1
0
        public void Configuration(CommandLineApplication command)
        {
            command.Description = "Tests the differences of the communication to the CoAP profile.";
            command.HelpOption("-?|-Help");

            var inputCsvOption = command.Option("-InputCsvFile <string>",
                                                "A name of an input file in csv format that contains decoded CoAP packets.",
                                                CommandOptionType.MultipleValue);

            var inputCapOption = command.Option("-InputCapFile <string>",
                                                "A name of an input file in cap format that contains CoAP packets.",
                                                CommandOptionType.MultipleValue);

            var profileOption = command.Option("-ProfileFile <string>",
                                               "A name of a profile file.",
                                               CommandOptionType.MultipleValue);

            var tresholdOption = command.Option("-TresholdFactor <double>",
                                                "A Factor used to scale the treshold. The usual values are between 0-1. Default is 1.",
                                                CommandOptionType.SingleValue);

            command.OnExecute(() =>
            {
                var thresholdMultiplier = tresholdOption.HasValue() ? Double.Parse(tresholdOption.Value()) : 1;
                if (profileOption.HasValue())
                {
                    var profiles = profileOption.Values.Select(PrintProfile.LoadProfile).ToList();
                    var profile  = profiles.Count == 1 ? profiles.First() : FlowProfile.MergeProfiles(profiles);
                    profile.ThresholdMultiplier = thresholdMultiplier;
                    if (inputCsvOption.HasValue())
                    {
                        var packets = PacketLoader.LoadCoapPacketsFromCsv(inputCsvOption.Value());
                        LoadAndTest(profile, packets);
                    }
                    if (inputCapOption.HasValue())
                    {
                        var packets = PacketLoader.LoadCoapPacketsFromCap(inputCapOption.Value());
                        LoadAndTest(profile, packets);
                    }
                    return(0);
                }
                throw new CommandParsingException(command, $"Missing required arguments: {inputCsvOption.ShortName}, {profileOption.ShortName}.");
            });
        }
Пример #2
0
        private void ProcessInput(string inputCsvFile, string inputCapFile, string outputFile, Settings settings)
        {
            var flowAggregation = settings.FlowAggregationFields;
            var protocolFactory = ProtocolFactory.Create(settings.Protocol);
            var modelKey        = protocolFactory.GetModelKeyFields(settings.ModelKey);

            Console.WriteLine("IRONSTONE FLOW PROFILING: Learn Profile");
            var profile = ProfileFactory.Create(protocolFactory, flowAggregation, modelKey, settings.ModelType, new string[] { "Packets", "Octets" }, settings.WindowSize);

            if (File.Exists(inputCsvFile))
            {
                var packets = PacketLoader.LoadCoapPacketsFromCsv(inputCsvFile).ToList();
                LoadAndCompute(profile, Path.GetFullPath(inputCsvFile), packets, settings.WindowSize, settings.WindowsCount, protocolFactory, modelKey, flowAggregation);
            }
            if (File.Exists(inputCapFile))
            {
                var packets = PacketLoader.LoadCoapPacketsFromCap(inputCapFile).ToList();
                LoadAndCompute(profile, Path.GetFullPath(inputCapFile), packets, settings.WindowSize, settings.WindowsCount, protocolFactory, modelKey, flowAggregation);
            }
            StoreProfile(profile, outputFile);
        }
Пример #3
0
        private void CreateTimelineForCoap(string inputfile, int interval, string selector)
        {
            var packets = PacketLoader.LoadCoapPacketsFromCap(inputfile).ToList();

            CreateTimelineForPackets <CoapPacketRecord>(packets, interval, x => x.CoapUriPath, x => x.TimeEpoch);
        }
Пример #4
0
        private void CreateTimelineForIec(string inputfile, int interval, string selector)
        {
            var packets = PacketLoader.LoadIecPacketsFromCap(inputfile).ToList();

            CreateTimelineForPackets <IecAsduPacket>(packets, interval, x => x.Cot, x => x.TimeEpoch);
        }