private void stopCaptureImpl() { try { if (_audioClient != null && _capClient != null) { _audioClient.Stop(); } // イベント発火 CaptureStoppedEventHandler del1 = CaptureStopped; if (del1 != null) { del1.Invoke(this, new CaptureStoppedEventArgs()); } DataUpdatedEventHandler del2 = DataUpdated; if (del2 != null) { del2.Invoke(this, new DataUpdatedEventArgs(new PitchResult(0, 0), ToneResult.Default)); } } catch (System.Runtime.InteropServices.COMException ex) { #warning エラー処理 throw new Exception(ex.Message); } }
private void StartCapture(int itemIndex) { packetCount = 0; device = CaptureDeviceList.Instance[itemIndex]; packetStrings = new Queue <PacketWrapper>(); bs = new BindingSource(); dataGridView.DataSource = bs; LastStatisticsOutput = DateTime.Now; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; device.Open(); // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); // disable the stop icon since the capture has stopped startStopToolStripButton.Image = global::WinformsExample.Properties.Resources.stop_icon_enabled; startStopToolStripButton.ToolTipText = "Stop capture"; }
private void btnStart_Click(object sender, EventArgs e) { device = CaptureDeviceList.Instance[cmbDeviceList.SelectedIndex]; device.Open(); device.Filter = "tcp and (port " + config.LoginAgentPort + " or port " + config.ZoneAgentPort + ") and host " + config.ServerIp; packetStrings = new Queue <A3Packet>(); packetData = new List <A3Packet>(); bs = new BindingSource(); dataGridPackets.DataSource = bs; BackgroundThreadStop = false; backgroundThread = new Thread(BackgroundThread); backgroundThread.Start(); arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; device.Open(); // start the background capture device.StartCapture(); btnStart.Enabled = false; btnStop.Enabled = true; lblStatus.Text = "Capturing packets started ..."; this.Text = this.Text + "*"; }
public void StartCapture(int itemIndex, string filter) { packetCount = 0; device = CaptureDeviceList.Instance[itemIndex]; //选折网卡 packetStrings = new Queue <PacketWrapper>(); LastStatisticsOutput = DateTime.Now; // start the background thread BackgroundThreadStop = false; backgroundThread = new Thread(BackgroundThread); backgroundThread.IsBackground = true; backgroundThread.Start(); // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); //当包抵达时要进行的操作 device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); //停止抓包要做的操作 device.OnCaptureStopped += captureStoppedEventHandler; device.Open(); device.Filter = filter; Debug.WriteLine("-- 正在监听网卡{0} {1},开始抓包!", device.Name, device.Description); // start the background capture device.StartCapture(); }
private void StartCapture(int itemIndex) { packetId = 0; device = CaptureDeviceList.Instance[itemIndex] as WinPcapDevice; arrivalEventHandler = new PacketArrivalEventHandler(OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; device.Open(OpenFlags.MaxResponsiveness, 1000); device.KernelBufferSize = 104857600; device.Filter = "ip and tcp"; device.StartCapture(); }
private ICaptureDevice InitializeDevice() { /* Retrieve the device list part of initialization*/ CaptureDeviceList devices = CaptureDeviceList.Instance; ICaptureDevice device = CaptureDeviceList.Instance[Convert.ToInt32(_config["packets:interface"])]; // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; return(device); }
public void StartCapture() { packetCount = 0; if (device is null) { device = CaptureDeviceList.Instance[0]; } packetQue = new Queue <IL2RPacket>(); //bs = new BindingSource(); //dataGridView.DataSource = bs; LastStatisticsOutput = DateTime.Now; // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); device.Open(); //filter to capture only packets from L2R that have data //string filter = "src port 12000 and len > 60"; device.Filter = filter; // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); //// disable the stop icon since the capture has stopped //startStopToolStripButton.Image = global::WinformsExample.Properties.Resources.stop_icon_enabled; //startStopToolStripButton.ToolTipText = "Stop capture"; }
private void StartCapture(int itemIndex, string filter) { packetCount = 0; device = CaptureDeviceList.Instance[itemIndex]; LastStatisticsOutput = DateTime.Now; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; int readTimeoutMilliseconds = 1000; device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds); string filter1 = "not arp"; if (!chkNull.isNull(filter)) { filter1 += " and " + filter; } // "ip and tcp " + filter;// and not src host " + txtHostIP.Text + " and not dst host " + txtHostIP.Text; device.Filter = filter1; // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); }
/// <summary> /// Start capturing packets. /// </summary> public void StartCapture() { packetCount = 0; if (device is null) { device = CaptureDeviceList.Instance[0]; } packetQue = new Queue <IL2RPacket>(); //bs = new BindingSource(); //dataGridView.DataSource = bs; LastStatisticsOutput = DateTime.Now; // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(Device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(Device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); device.Open(); //filter to capture only packets from L2R that have data //string filter = "src port 12000 and len > 60"; device.Filter = filter; // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); }
private void StartCapture() { packetCount = 0; //device = devices[itemIndex]; packetStrings = new Queue <PacketWrapper>(); bs = new BindingSource(); dataGridView.DataSource = bs; LastStatisticsOutput = DateTime.Now; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; var interval = 0; int.TryParse(textBoxInterfaceMonitorInterval.Text, out interval); device.Open(DeviceMode.Normal, interval); // device filter add if (textBoxCaptureFilter.Text != "") { device.Filter = textBoxCaptureFilter.Text; } // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); }
private void StartCapture(int itemIndex) { packetCount = 0; device = CaptureDeviceList.Instance[itemIndex]; // set device name deviceNameLbl.Text = device.Name.Substring(device.Name.LastIndexOf('\\') + 1, device.Name.Length - device.Name.LastIndexOf('\\') - 1); packetStrings = new Queue <PacketWrapper>(); bs = new BindingSource(); dataGridView.DataSource = bs; LastStatisticsOutput = DateTime.Now; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; device.Open(DeviceMode.Normal, readTimeout); // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); // disable the stop icon since the capture has stopped statusImage.LoadAsync("Resources/work.png"); startToolStripMenuItem.Text = "Stop capture"; startToolStripMenuItem.Image = Properties.Resources.stopbtn; }
private void StartCapture() { _packetCount = 0; _device = _devices[_view.SelectedDevice]; packetStrings = new Queue <PacketWrapper>(); bs = new System.Windows.Forms.BindingSource(); _view.SetDataSource(bs); LastStatisticsOutput = DateTime.Now; _backgroundThread = new Thread(BackgroundThreadFunc); _backgroundThreadStop = false; _backgroundThread.Start(); arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); _device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); _device.OnCaptureStopped += captureStoppedEventHandler; _device.Open(); captureStatistics = _device.Statistics; UpdateCaptureStatistics(); _device.StartCapture(); }
private void StartCapture(int itemIndex) { packetCount = 0; device = CaptureDeviceList.Instance[itemIndex]; packetStrings = new Queue<PacketWrapper>(); bs = new BindingSource(); dataGridView.DataSource = bs; LastStatisticsOutput = DateTime.Now; // start the background thread BackgroundThreadStop = false; backgroundThread = new System.Threading.Thread(BackgroundThread); backgroundThread.Start(); // setup background capture arrivalEventHandler = new PacketArrivalEventHandler(device_OnPacketArrival); device.OnPacketArrival += arrivalEventHandler; captureStoppedEventHandler = new CaptureStoppedEventHandler(device_OnCaptureStopped); device.OnCaptureStopped += captureStoppedEventHandler; device.Open(); // force an initial statistics update captureStatistics = device.Statistics; UpdateCaptureStatistics(); // start the background capture device.StartCapture(); // disable the stop icon since the capture has stopped startStopToolStripButton.Image = global::WinformsExample.Properties.Resources.stop_icon_enabled; startStopToolStripButton.ToolTipText = "Stop capture"; }
private void _StopCapture() { // if capturing was not started, just return if (null == _curNIC) { return; } _requestStop = true; _threadObject.Join(); _threadObject = null; _curNIC.OnPacketArrival -= _eventPacketArrival; _curNIC.OnCaptureStopped -= _eventCaptureStopped; _eventPacketArrival = null; _eventCaptureStopped = null; _curNIC = null; }
private bool _StartCapture() { // if capturing is already started, just return true if (null != _curNIC) { return true; } int nSelectedNIC = OConfiguration.instanceOf().GetSelectedNIC(); if (nSelectedNIC < 0) { MessageBox.Show("There is no device selected.", "Error"); return false; } if (nSelectedNIC >= CaptureDeviceList.Instance.Count) { MessageBox.Show("The selected device is not valid. Select device again", "Error"); return false; } // clear all packet before starting capture _capturedPackets.Clear(); // clear all current packet list _curPacketList.Clear(); // clear ui lstPackets.Items.Clear(); hexEdit.ByteProvider = null; _curNIC = CaptureDeviceList.Instance[nSelectedNIC]; _threadObject = new Thread(_ThreadProc); _threadObject.Start(); // Set up capture _eventPacketArrival = new PacketArrivalEventHandler(_OnPacketArrival); ; _eventCaptureStopped = new CaptureStoppedEventHandler(_OnCaptureStopped); _curNIC.OnPacketArrival += _eventPacketArrival; _curNIC.OnCaptureStopped += _eventCaptureStopped; _curNIC.Open(); // start capture _curNIC.StartCapture(); return true; }