Тема: PcapDotNet, показує невірну довжину пакета
Хай. Написав програмку, котра моніторить усі пакети на певному інтерфейсі, і от задав їй фільтр по протоколоу ICMP (ну це типу ping). І пінгую сайтик.
В cmd пише, що відправлено 32 байти, а в програмці пише, що 74.
Чому так?
Скріншот
Код
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PcapDotNet.Core;
using PcapDotNet.Packets;
namespace CourseNetwork
{
    public partial class Form1 : Form
    {
        private PacketDevice device;
        private PacketCommunicator communicator;
        public Form1()
        {
            InitializeComponent();
            backgroundWorker1.WorkerSupportsCancellation = true;
        }
        private void btnGLD_Click(object sender, EventArgs e)
        {
            bindingSource1.DataSource = LivePacketDevice.AllLocalMachine;
            cbDevices.DataSource = bindingSource1.DataSource;
            cbDevices.DisplayMember = "Description";
        }
        private void btnCapture_Click(object sender, EventArgs e)
        {
            if (backgroundWorker1.IsBusy)
            {
                backgroundWorker1.CancelAsync();
                btnCapture.Text = "Start capture";
            }
            else
            {
                device = (PacketDevice)cbDevices.SelectedItem;
                if (device != null)
                {
                    backgroundWorker1.RunWorkerAsync(device);
                    btnCapture.Text = "Stop capture";
                }
                else
                {
                    MessageBox.Show("At first u have to select a device");
                }
            }
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            device = (PacketDevice) e.Argument;
            communicator = device.Open(65536, PacketDeviceOpenAttributes.Promiscuous, -1);
            Packet packet;
            while (true)
            {
                if (backgroundWorker1.CancellationPending) {e.Cancel = true; return;}
                
                PacketCommunicatorReceiveResult result = communicator.ReceivePacket(out packet);
                if (result == PacketCommunicatorReceiveResult.Ok)
                    dgvData.Invoke(new Action(() => { dgvData.Rows.Insert(0,packet.Ethernet.IpV4.Source, packet.Ethernet.IpV4.Destination, packet.Ethernet.IpV4.Protocol,
                        packet.Length,packet.Timestamp); }));
            }
        }
        private void Form1_Resize(object sender, EventArgs e)
        {
            dgvData.Size = new Size(Width - 31, Height-103); 
        }
        private void btnFilter_Click(object sender, EventArgs e)
        {
            if(communicator!=null)
            communicator.SetFilter(textBox1.Text);
        }
           
    }
}