开发者

multicast basics - lost data

Is it a basic principle on reading multicast开发者_Python百科 data that if your application doesn't process the next datagram that's come in before another one comes in that the first one is essentially overwritten? I've done some experimenting and increasing receive_buffer sizes has no effect on what I'm describing. In other words there seems to be no low level queuing of multicast datagrams by the windows OS or NIC card software.

Am I understanding this correctly? Or is there some socket option or control that can help with this?


Windows XP has a 8KB default socket buffer, Vista and later has a 64KB default socket buffer. You can override this with SO_RCVBUF, it is recommended to never set to 0 unlike SO_SNDBUF for zero-copy when using IOCP.

Usually with socket buffers the queue fills up and starts dropping new packets, so with a large buffer you can end up with stale out-of-date messages waiting in the buffer taking precedence over newer fresh data.

The design you need to follow is a high priority thread in a tight loop reading packets as fast as possible from the network and inserting into a larger application queue for later processing if your business logic is slower. When using IOCP you can post several blocking recv calls to minimize data loss but as the MSDN documentation states there is no guarantee on order of completions on the completion port.


If by multicast you mean UDP, then there is no guarantee of data ordering or even arrival of data when using the protocol.

If you are processing received packets inline, then you can definitely miss incoming data while doing that and should consider handing off each packet to a separate thread for processing, so that you can post another receive asap. This would minimize data loss within the constraints ot the protocol and your particular network config.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜