0

I'm sending an ordered sequence of datagram from a server to client in C UNIX. I'm using Berkeley' sockets. The server has a counter that is incremented when a datagram is sent. Each datagram contains this counter as data value. So client read a sequence of datagrams where each datagram has the order number inside its data field.

Server and client are on the same machine so I'm using UDP on LOCALHOST.

The problem is that I lose packets.

In fact, when I'm reading the value of these datagrams I can't find some numbers. It's possible that UDP loses packet in localhost? I'm sending 10000 datagrams overall, but I can see the problem usually early. Already around 150 packages I often experience losses.


Wireshark can see the losses datagrams. Why my client not? where do they end up? If I lose packets I think that also Wireshark can't see these packets. But in my case, Wireshark sees all ok every time.

ABC
  • 71
  • 9
  • 1
    Your kernel won't keep inifinite buffers. – Mat Sep 22 '20 at 08:58
  • 1
    If someone is sending your program packets faster than you can read and process them, they get dropped before they reach your program. There's a limited amount of buffer space available. (Or you have a local firewall dropping them, or they're sent to the wrong port ) – nos Sep 22 '20 at 08:59
  • But why on the point of view of Wireshark is all ok? – ABC Sep 22 '20 at 08:59
  • 2
    Cause wireshark captures the packets before they reach your program – nos Sep 22 '20 at 08:59
  • Does Wireshark have a special privilegies? Wirehsark isn't a normal program? – ABC Sep 22 '20 at 09:00
  • 1
    yes it does, it integrates with the operating system at a deep level to capture packets (Or uses a library/kernel driver to do so) – nos Sep 22 '20 at 09:01
  • 2
    Imagine two persons are talking. One is speaking and another is NOT listening. Your program is the one not listening while wireshark is the stalker. Wireshark doesn't listen from your program but listen the channel between programs. – Louis Go Sep 22 '20 at 09:01
  • Ok nice. So I'm experimenting packet loss in UDP localhost. I thought it was a very rare event. Packets lost due to slow client. Thanks to all! – ABC Sep 22 '20 at 09:03

0 Answers0