This project is read-only. Receive udp lost packet high stream

Feb 15, 2014 at 6:26 AM
i am using receive of library, but by sending about 10000 udp packet in a second from another host (linked point to point or directly through an ethernet switc at gigabit eth), i lost a lot of packet.
by using wireshark packet arrives correctly (10000 packet are found on wireshark).
What is the problem??
i will try the same example on c++ , with winpcap used directly , i want to see if the problem is due to or it is a general problem (i don't believe this last hypotesis ... wireshark run ok)
Feb 15, 2014 at 10:41 AM
Hi deuctator,

Can you share the code you use to capture and handle the packets?
You should handle them as fast as possible, so the buffer won't overflow.
You can also control some parameters that will be best for such traffic, and look at packet statistics to see where do the packets get lost.

Feb 15, 2014 at 8:03 PM
I am using the example of url

but my
   private static void PacketHandler(Packet packet)
    { ...

make a print every 1000 packets arrived ...
Wireshark read packets correctly , my library using pcapnet lose several packets
Feb 21, 2014 at 8:20 AM
You might want to increase the buffer or handle the packet more quickly so the buffer won't get filled while you're handling the packets.
Feb 21, 2014 at 8:29 AM
i am now using capture without callback. In which way can i increase the buffer??? can you make an example?

i write my code
Private Sub CaptureFunction()
    Dim allDevices As IList(Of LivePacketDevice)
    Dim deviceIndex As Integer = 0
    'Dim SourceMac As String = "10:60:4B:75:28:2E" 'PC LAB
    'Dim SourceMac As String = "00:1b:d3:86:db:52" 'CF30  
    Dim SourceMac As String = "00:1f:29:3c:43:89" 'PClinux  
    Dim DestinationMac As String = "e4:11:5b:33:2c:78" 'PC MIO  
    Dim filter As BerkeleyPacketFilter
    allDevices = LivePacketDevice.AllLocalMachine

    If allDevices.Count > 0 Then
        selectedDevice = CType(allDevices(0), PacketDevice)
    End If

    communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)

    If communicator.DataLink.Kind <> DataLinkKind.Ethernet Then

    End If

    System.Console.WriteLine("Listening on " + selectedDevice.Description + "...")

    filter = communicator.CreateFilter("ether src " + SourceMac + " and ether dst " + DestinationMac)
    communicator.Mode = PacketCommunicatorMode.Capture
    'communicator.ReceivePackets(0, AddressOf PacketHandler)

    Dim packet As Packet
    Dim result As PacketCommunicatorReceiveResult
    Dim ip As IpV4Datagram
    Dim udp As UdpDatagram
    Dim i As Integer = 0
    While True
        If StopFlag Or AbortFlag Then
            Exit While
        End If

        result = communicator.ReceivePacket(packet)
        Select Case result
            Case PacketCommunicatorReceiveResult.Timeout
                ' Timeout elapsed
                '  System.Console.WriteLine("Timeout ")  
                Continue While
            Case PacketCommunicatorReceiveResult.Ok

                ip = packet.Ethernet.IpV4
                udp = ip.Udp

                Buffer.BlockCopy(packet.Buffer, PAYLOAD_OFFSET, AcqBufTOT, m_numpktcpy * m_payloadEthSize, packet.Buffer.Length - PAYLOAD_OFFSET)

                If numpaccetticont Mod 10000 = 0 Then
                    System.Console.WriteLine(packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") + "  Packet length:" + CStr(packet.Length) + "   pacchetto numero  " + CStr(numpaccetticont))
                End If

                m_numpktcpy = m_numpktcpy + 1

        End Select

    End While

End Sub
Mar 8, 2014 at 2:35 PM
  1. PacketComunicator.SetKernelBufferSize()
  2. PacketComunicator.SetKernelMinimumBytesToCopy()
Mar 8, 2014 at 2:58 PM
thank you so much , i have increased the amount of kernel buffer size already .
is it possible that on windows xp i lose no packet, instead on win7 i lose for example 5 6 packet on 200000 ?? what is the reason ??
i have tried in same condition , with several source (linux, windows, fpga TEMAC).
Mar 8, 2014 at 4:53 PM
Have you tried this?
communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.MaximumResponsiveness, 1000);
Mar 11, 2014 at 5:18 PM
No change using MaximumResponsiveness option.

I have obtained a better performanze using SetKernelBufferSize at 8 MB, but on Windows XP all run very well (no packet loss), on Windows 7 i have a little packet loss in same condition
Mar 14, 2014 at 11:17 AM
Is the only difference between machines is the operating system or do the machines also have some difference in hardware?
Mar 15, 2014 at 4:51 PM
Edited Mar 25, 2014 at 4:07 PM
I think that reason is linked to the hardware :
1) the host with windows xp is A panasonic CF 30 (Intel(R) 82567LM Gigabit Ethernet) with this i have no packet loss
2) the hosts win7 64bit (Intel(R) 82579LM Gigabit Ethernet), with this i have a little packet loss problem
my streaming was about 112 Mbps
i have also tryied a windows xp with Intel(R) 82579LM Gigabit Ethernet where i obtain however packet loss
i have tryied another old pc with Win XP and a Broadcom Nextreme Gigabit Ethernet where i have not packet loss until 112 Mpbs
my kernel buffer was set to comunicator.SetKernelBufferSize(16 * 1024 * 1024) but i have also tryied with 32 MB
In which way can i solve this packet loss problem??
Mar 28, 2014 at 7:37 AM
Can you check PacketTotalStatistics to see why packets were dropped?