public void Setup()
 {
     _conversationTable = FasterConversationTable.Create($"{dataset}.{loadTableRun}", 3000000);
     using (var loader = _conversationTable.GetStreamer())
         using (var pcapReader = new SharpPcapReader(dataset))
         {
             while (pcapReader.GetNextFrame(out var rawFrame))
             {
                 loader.AddFrame(rawFrame);
             }
             loader.Close();
         }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a conversation table from the given collection of <paramref name="frames"/>.
        /// </summary>
        /// <param name="frames">Source frames used to populate conversation table.</param>
        /// <param name="conversationTablePath">The path to folder where conversation table is to be saved.</param>
        /// <param name="token">The cancellation token for interrupting the operation.</param>
        /// <returns>Newly created conversation table.</returns>
        public FasterConversationTable CreateConversationTable(IEnumerable <RawCapture> frames, string conversationTablePath, int framesCapacity, CancellationToken?token = null)
        {
            var flowTable = FasterConversationTable.Create(conversationTablePath, framesCapacity);

            using (var loader = flowTable.GetStreamer())
            {
                foreach (var frame in frames)
                {
                    loader.AddFrame(frame);
                    if (token?.IsCancellationRequested ?? false)
                    {
                        break;
                    }
                }
            }
            flowTable.SaveChanges();
            return(flowTable);
        }
Ejemplo n.º 3
0
        public void TestCreateTable()
        {
            var sw       = new Stopwatch();
            var pcapPath = Path.GetFullPath(@"data\PCAP\modbus.pcap");
            var dbPath   = Path.GetFullPath(@"c:\temp\0001\");

            if (Directory.Exists(dbPath))
            {
                Directory.Delete(dbPath, true);
            }

            var flowTable   = FasterConversationTable.Create(dbPath, framesCapacity: 1700000);
            var frameNumber = 0;

            sw.Restart();
            using (var loader = flowTable.GetStreamer())
                using (var pcapReader = new SharpPcapReader(pcapPath))
                {
                    while (pcapReader.GetNextFrame(out var rawFrame))
                    {
                        frameNumber++;
                        loader.AddFrame(rawFrame);
                    }
                    loader.Close();
                }

            Console.WriteLine($"--- LOADED --- [{sw.Elapsed}]");
            sw.Restart();
            Console.WriteLine($"Convs= {flowTable.ConversationsCount} [{sw.Elapsed}]");
            sw.Restart();
            Console.WriteLine($"Frames= {flowTable.FramesCount} /{frameNumber} [{sw.Elapsed}]");
            sw.Restart();
            flowTable.SaveChanges();
            Console.WriteLine($"--- COMMITED --- [{sw.Elapsed}]");
            sw.Restart();
            Console.WriteLine($"Frames= {flowTable.FramesCount} / {frameNumber} [{sw.Elapsed}]");

            flowTable.Dispose();
        }