I am developing a VB.NET application that needs to monitor a multicast group. To do this I am using the System.Net.UdpClient class. The multicast group messages are of a fixed size (48 bytes) and each member of the group sends the message about one every second. In my test setup I have a single device sending the group message and my application is monitoring the messages.
What I see using WireShark is exactly what I expect, a multicast message with 48 bytes in the data element of the message.
The application uses the following code to block (in a separate thread) waiting for the messages:
While Not done
Dim bytes As Byte() = listener.Receive(groupEP)
... process message here
Typically, the length of "bytes" is the size of the message (48 bytes), however, sometimes many more bytes are returned, even though the time delay between the previous good message and the long one is consistently about 1 second. The data in the buffer appears to be a partial message (first few bytes missing) and then many well formed messages.
As I said, I have examined the network data using WireShark and all the messages are well formed. Also, there are only messages from my single device.
Am I missing something obvious here?
Any pointers as to what may be going wrong would be much appreciated.