public void ProcessPcap(string filePath) { try { RaiseFileProcessingStatusChangedEvent(FileProcessingStatus.Started, filePath); _tcpSessionsBuilder.Clear(); _udpStreamBuilder.Clear(); ReadPcapFile(filePath); // Raise event for each Tcp session that was built. // TODO: think about detecting complete sessions on the fly and raising // events accordingly. foreach (var session in this._tcpSessionsBuilder.Sessions) { TcpSessionArrived?.Invoke(this, new TcpSessionArivedEventArgs() { TcpSession = session }); } foreach (var session in this._udpStreamBuilder.Sessions) { UdpSessionArrived?.Invoke(this, new UdpSessionArrivedEventArgs() { UdpSession = session }); } _processingPrecentsPredicator.NotifyAboutProcessedFile(new FileInfo(filePath)); RaiseFileProcessingStatusChangedEvent(FileProcessingStatus.Finished, filePath); } catch (Exception ex) { RaiseFileProcessingStatusChangedEvent(FileProcessingStatus.Faild, filePath); } }
public void ProcessPcap(string filePath) { try { FileProcessingStarted?.Invoke(this, new FileProcessingStartedEventArgs() { FilePath = filePath }); _tcpSessionsBuilder.Clear(); _udpStreamBuilder.Clear(); // Get an offline device, handle packets registering for the Packet // Arrival event and start capturing from that file. // NOTE: the capture function is blocking. ICaptureDevice device = new CaptureFileReaderDevice(filePath); device.OnPacketArrival += new PacketArrivalEventHandler(ProcessPacket); device.Open(); device.Capture(); // Raise event for each Tcp session that was built. // TODO: think about detecting complete sesions on the fly and raising // events accordingly. foreach (var session in this._tcpSessionsBuilder.Sessions) { TcpSessionArrived?.Invoke(this, new TcpSessionArivedEventArgs() { TcpSession = session }); } foreach (var session in this._udpStreamBuilder.Sessions) { UdpSessionArrived?.Invoke(this, new UdpSessionArrivedEventArgs() { UdpSession = session }); } _processingPrecentsPredicator.NotifyAboutProcessedFile(new FileInfo(filePath)); FileProcessingEnded?.Invoke(this, new FileProcessingEndedEventArgs() { FilePath = filePath }); } catch (Exception ex) { //throw new PcapFileProcessingException(filePath); } }
private void ClearOldSniffingsData() { _udpStreamBuilder.Clear(); _tcpSessionsBuilder.Clear(); _packets.Clear(); }