Android udp packets loss

2019-07-20 09:33发布

问题:

I am facing weird problem in receiving udp packets on Sony Xperia Z tablet. My application didn't receive many udp packets. So I have rooted the tablet to install the shark app and captured the network traffic using shark app after rooting the device. When I analyzed the report, the device has received all the packets but my application did not receive many of them. If the application didn't receive any packets, issue could be the packet filter which blocks broadcast packets. Here, my application receives few packets but misses packets received by device. I have not observed this issue with samsung tab 2 and motorola xoom tablet where it receives all the packets. It sounds like there is no code issue. Have anybody faced similar problem? Let me know if you have any suggestions or inputs that I can try.

UPDATE:

I have added my comments below.

回答1:

I'd tell you a UDP joke, but you might not get it.

Packet loss is a documented feature of the UDP protocol.

UDP protocol does not guarantee that the package will be delivered to the addressee. http://en.wikipedia.org/wiki/User_Datagram_Protocol



回答2:

I have found why my app missed some packets received by device. I have set datagram socket receiver buffer size to small value. I removed this code setting buffer size and then it strated receving all the packets. By default, android sets buffer size as 163840B but I set the size to 64 bytes. It is working fine with default buffer size set by android.



标签: android udp