Beispiel #1
0
        public void AddCapturefiles(CapFile[] capFiles)
        {
            foreach (CapFile capFile in capFiles)
            {
                //merge beacons
                HashSet <BeaconFrame> beacons = new HashSet <BeaconFrame>(capFile.Beacons.AsEnumerable(), new BeaconFrame());
                beacons.UnionWith(this._beacons.AsEnumerable());

                _beacons.Clear();
                _beacons.AddRange(beacons.ToArray());


                //merge Access Points
                HashSet <AccessPoint> APs = new HashSet <AccessPoint>(capFile.AccessPoints.AsEnumerable(), new AccessPoint());
                APs.UnionWith(this.AccessPoints.AsEnumerable());

                _accessPoints.Clear();

                foreach (AccessPoint AP in APs.ToArray())
                {
                    long MacAddrNumber = Utils.MacToLong(AP.BeaconFrame.MacAddress);
                    _accessPoints.Add(MacAddrNumber, AP);
                }


                //merge Stations
                HashSet <Station> stations = new HashSet <Station>(capFile.Stations.AsEnumerable(), new Station());
                stations.UnionWith(Stations.AsEnumerable());

                _stations.Clear();
                foreach (Station station in stations.ToArray())
                {
                    long MacAddrNumber = Utils.MacToLong(station.SourceMacAddress);
                    _stations.Add(MacAddrNumber, station);
                }

                //merge Data Frames
                HashSet <DataFrame> dataFrames = new HashSet <DataFrame>(_dataFrames, new DataFrame());
                dataFrames.UnionWith(capFile.DataFrames);

                _dataFrames.Clear();
                _dataFrames.AddRange(dataFrames.ToArray());

                //merge Auth Request Frames
                HashSet <AuthRequestFrame> authFrames = new HashSet <AuthRequestFrame>(_authRequestFrames, new AuthRequestFrame());
                authFrames.UnionWith(capFile.AuthRequestFrames.AsEnumerable());

                _authRequestFrames.Clear();
                _authRequestFrames.AddRange(authFrames.ToArray());
            }

            foreach (Station station in _stations.Values)
            {
                station.CaptureInfo = this;
            }


            //link all the DataFrames to the Stations
            int DataFrameCount         = _dataFrames.Count;
            int DataFrameProgressValue = 0;

            SortedList <long, Station> StationList = new SortedList <long, Station>();

            foreach (Station station in _stations.Values)
            {
                long MacSourceAddrNumber = Utils.MacToLong(station.SourceMacAddress);
                station.ClearDataFrames();

                if (!StationList.ContainsKey(MacSourceAddrNumber))
                {
                    StationList.Add(MacSourceAddrNumber, station);
                }
            }

            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < _dataFrames.Count; i++)
            {
                Station station = null;
                if (StationList.TryGetValue(_dataFrames[i].SourceMacAddressLong, out station) ||
                    StationList.TryGetValue(_dataFrames[i].TargetMacAddressLong, out station))
                {
                    station.AddDataFrame(_dataFrames[i]);
                    _dataFrames.RemoveAt(i);
                    i--;
                    DataFrameProgressValue++;

                    if (onDataFrameProgress != null && sw.ElapsedMilliseconds >= 1000)
                    {
                        onDataFrameProgress(DataFrameProgressValue, DataFrameCount);
                        sw = Stopwatch.StartNew();
                    }
                }
            }
        }