Пример #1
0
        public void CalculateSingleHistogramData()
        {
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

            // Get the batch intervals
            CurrentCaptureFile captureFile = new CurrentCaptureFile();
            captureFile = pcp.GetCurrentCaptureFile(_CaptureFileName);
            batchIntervals = pcp.GetMarkedBatchIntervals(captureFile.CaptureBatchId);

            CalculateSingleHistogramProbability(batchIntervals, BatchType.Single, captureFile);

            //switch (_CaptureState)
            //{
            //    case CaptureState.Marked:
            //        CalculateHistogramDataByType(batchIntervals, BatchType.Single, CaptureState.Marked);
            //        break;
            //    case CaptureState.Unmarked:
            //        CalculateHistogramDataByType(batchIntervals, BatchType.Single, CaptureState.Unmarked);
            //        break;
            //}
        }
Пример #2
0
        public bool CalculateSingleBatchStatistics()
        {
            bool result = false;

            // Calculate single batch statistics
            //// Get the last marked and unmarked batches and add them to the graph
            //int lastBatchId = 0;
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            //lastBatchId = pcp.GetLastCaptureBatchId();
            CurrentCaptureFile captureFile = new CurrentCaptureFile();
            CaptureFileData cfd = new CaptureFileData();
            //captureFile = cfd.GetLastCaptureBatchRecord();
            captureFile = cfd.GetCurrentCaptureFile(_CaptureFileName);

            // Set the global variable
            _CaptureState = captureFile.CaptureState;

            BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

            // Calculate probabilities
            batchIntervals = pcp.GetMarkedBatchIntervals(captureFile.CaptureBatchId);
            int histogramBinSize = Convert.ToInt32(_HistogramBinSize);
            SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_TrimZeroPacketIntervals, histogramBinSize);

            BatchStatistics markedSingleStats = new BatchStatistics();
            BatchStatistics unmarkedSingleStats = new BatchStatistics();

            // Add the results to the DisplayStatistics table
            DisplayStatisticsData dsd = new DisplayStatisticsData();
            if(captureFile.CaptureState == CaptureState.Marked)
            {
                markedSingleStats = CalculateBatchStatistics(batchIntervals, CaptureState.Marked, BatchType.Single);
            }
            else
            {
                unmarkedSingleStats = CalculateBatchStatistics(batchIntervals, CaptureState.Unmarked, BatchType.Single);
            }
            return result;
        }
Пример #3
0
        public bool CalculateSingleBatchStatisticsForLastTwoBatches()
        {
            bool result = false;

            // Calculate single batch statistics
            // Get the last marked and unmarked batches and add them to the graph
            BindingList<CurrentCaptureFile> lastBatchIds = new BindingList<CurrentCaptureFile>();
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            lastBatchIds = pcp.GetLastCaptureBatchIds();

            foreach (CurrentCaptureFile file in lastBatchIds)
            {
                BindingList<BatchIntervalMarked> batchIntervals = new BindingList<BatchIntervalMarked>();

                // Calculate probabilities
                batchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                int histogramBinSize = Convert.ToInt32(_HistogramBinSize);
                SortedDictionary<int, decimal> probabilities = new CalculateProbability(batchIntervals).GetProbabilityByPacketRange(_TrimZeroPacketIntervals, histogramBinSize);
            }

            return result;
        }
Пример #4
0
        private void RefreshSingleBatchStatistics()
        {
            // Get the last marked and unmarked batches
            BindingList<CurrentCaptureFile> lastBatchIds = new BindingList<CurrentCaptureFile>();
            ProcessCapturePackets pcp = new ProcessCapturePackets();
            lastBatchIds = pcp.GetLastCaptureBatchIds();

            // Get the batch intervals
            BindingList<BatchIntervalMarked> unmarkedBatchIntervals = new BindingList<BatchIntervalMarked>();
            BindingList<BatchIntervalMarked> markedBatchIntervals = new BindingList<BatchIntervalMarked>();

            foreach (CurrentCaptureFile file in lastBatchIds)
            {
                if (file.CaptureState == CaptureState.Marked)
                {
                    markedBatchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                }
                else if(file.CaptureState == CaptureState.Unmarked)
                {
                    unmarkedBatchIntervals = pcp.GetMarkedBatchIntervals(file.CaptureBatchId);
                }
                else
                {
                    MessageBox.Show("Error retrieving batch intervals: capture state is unknown!", "GetMarkedBatchIntervals by CaptureBatchId", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            BatchStatistics markedSingleStats = new BatchStatistics();
            BatchStatistics unmarkedSingleStats = new BatchStatistics();

            // Get this data from DisplayStatistics table; except on refresh...
            //AnalysisEngine ae = new AnalysisEngine();
            //markedSingleStats = ae.GetBatchStatistics(markedBatchIntervals, CaptureState.Marked, BatchType.Single);
            //unmarkedSingleStats = ae.GetBatchStatistics(unmarkedBatchIntervals, CaptureState.Unmarked, BatchType.Single);

            // Load up the table
            // Single unmarked column
            int row = 0;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = unmarkedSingleStats.IntervalCount;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = TrimIntervals == true ? unmarkedSingleStats.IntervalCountTrimmed.ToString() : "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = string.Format("{0:N2}", unmarkedSingleStats.PacketCountMean);
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = string.Format("{0:N2}", unmarkedSingleStats.PacketCountStandardDeviation);
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = unmarkedSingleStats.PacketCountMinimum;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = unmarkedSingleStats.PacketCountMaximum;
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[1].Value = "N/A";

            // Single marked column
            row = 0;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = markedSingleStats.IntervalCount;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = TrimIntervals == true ? markedSingleStats.IntervalCountTrimmed.ToString() : "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = string.Format("{0:N2}", markedSingleStats.PacketCountMean);
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = string.Format("{0:N2}", markedSingleStats.PacketCountStandardDeviation);
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = markedSingleStats.PacketCountMinimum;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = markedSingleStats.PacketCountMaximum;
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[2].Value = "N/A";

            // Single variance column
            row = 0;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = unmarkedSingleStats.IntervalCount - markedSingleStats.IntervalCount;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = TrimIntervals == true ? (unmarkedSingleStats.IntervalCountTrimmed - markedSingleStats.IntervalCountTrimmed).ToString() : "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = string.Format("{0:N2}", (unmarkedSingleStats.PacketCountMean - markedSingleStats.PacketCountMean));
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = string.Format("{0:N2}",(unmarkedSingleStats.PacketCountStandardDeviation - markedSingleStats.PacketCountStandardDeviation));
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = unmarkedSingleStats.PacketCountMinimum - markedSingleStats.PacketCountMinimum;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = unmarkedSingleStats.PacketCountMaximum - markedSingleStats.PacketCountMaximum;
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = "N/A";
            _AnalysisDataGridView.Rows[row++].Cells[3].Value = "N/A";
        }