This project is read-only.

Failed transmiting packets from queue error

Jan 18, 2013 at 11:50 AM

i try to send buffer using the send buffer example and got this error:

Failed transmiting packets from queue. WinPcap Error: Error opening adapter: Error opening adapter: Error opening adapter: Error

stack trace: 

   at PcapDotNet.Core.PacketSendBuffer.Transmit(pcap* pcapDescriptor, Boolean isSync)   at PcapDotNet.Core.LivePacketCommunicator.Transmit(PacketSendBuffer sendBuffer, Boolean isSync)   at SendQueue.Program.Main(String[] args) in d:\Drivers\projects\SendQueue\SendQueue\Program.cs:line 50   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)   at System.Threading.ThreadHelper.ThreadStart()

this error occurs after sending few packets of my pcap file

my pcap file: http://www.freefilehosting.net/chikka114012013-13034019201637 

my code:

        static void Main(string[] args)
        {            
            IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;
            for (int i = 0; i != allDevices.Count; ++i)
            {
                LivePacketDevice device = allDevices[i];
                Console.Write((i + 1) + ". " + device.Name);
                if (device.Description != null)
                {
                    Console.WriteLine(" (" + device.Description + ")");
                }
                else
                {
                    Console.WriteLine(" (No description available)");
                }
            }

            PacketDevice selectedOutputDevice = allDevices[int.Parse(args[0])];
            long capLength = new FileInfo(args[1]).Length;
            bool isSync = true;
            OfflinePacketDevice selectedInputDevice = new OfflinePacketDevice(args[1]);

            using (PacketCommunicator inputCommunicator = selectedInputDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000))
            {
                using (PacketCommunicator outputCommunicator = selectedOutputDevice.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000))
                {
                    using (PacketSendBuffer sendBuffer = new PacketSendBuffer((uint)capLength))
                    {
                        int numPackets = 0;
                        Packet packet;
                        while (inputCommunicator.ReceivePacket(out packet) == PacketCommunicatorReceiveResult.Ok)
                        {
                            sendBuffer.Enqueue(packet);
                            ++numPackets;
                        }

                        outputCommunicator.Transmit(sendBuffer, isSync);
                    }
                }
            }
        }


Jan 18, 2013 at 5:32 PM

Hi,

 

Did you try increasing the PacketSendBuffer size to a bigger size?

 

Boaz.

Jan 18, 2013 at 7:54 PM
Edited Jan 18, 2013 at 7:55 PM

i made a little fix cause the crash occur in packet with bad checksum:

 

                        using (PacketSendBuffer sendBuffer = new PacketSendBuffer((uint)capLength * 5))
                        {
                            int numPackets = 0;
                            Packet packet;
                            Packet tmpPacket;
                            while (inputCommunicator.ReceivePacket(out packet) == PacketCommunicatorReceiveResult.Ok)
                            {
                                if (packet.IsValid)
                                {
                                    sendBuffer.Enqueue(packet);
                                    ++numPackets;
                                }
                            }

                            try
                            {
                                outputCommunicator.Transmit(sendBuffer, isSync);
                            }
                            catch (Exception)
                            {
                            }
                        }

but i do not understand why i have crash after finish to send all the packet at the end (just windows error that vshost32.exe has stopped working)

Jan 18, 2013 at 7:57 PM

Can you run this in Visual Studio, catch the exception and copy it here?

Jan 18, 2013 at 8:35 PM
Edited Jan 18, 2013 at 8:38 PM

i cannot catch the exception, i try with breakpoint but it does not get into the exception 

maybe try to copy my code and run on your machine, the crash occur after send all the packets

Jan 19, 2013 at 8:11 AM

Can you try to debug this and see if this happens if the pcap file is empty?

How many packets are needed there?

Do specific packets cause it? 

What happens if isSync is false?

More information on the crash would be helpful.

Jan 19, 2013 at 9:31 AM

i cannot create an empty pcap file.

i used pcap file with only 3 packets and the crash is afetr all the packets played successfully even is  isSync is false.

i cannot provide more details but this happen only in debug mode, if i use command line this wont happen

Jan 19, 2013 at 11:45 AM

Can you try and remove lines from the code to see which lines cause this?

Jan 19, 2013 at 2:30 PM

i am using your example so i don't know if i can remove lines from this code and it will work

Jan 24, 2013 at 7:54 PM

Are you using Pcap.Net example as is?

Have you changed anything from the original example?

Jan 24, 2013 at 10:16 PM
Edited Jan 25, 2013 at 4:43 AM

yes i am you using Pcap.Net example as is and did not change anything

can you try to copy this code and run ?

Apr 16, 2013 at 8:16 AM
Sorry for not responding in a while,

I'm still working on fixing this issue.

Boaz.