I subscribe to UDP multicast stream in MATLAB. This cannot be done initially, so instead I use an object java.net.MulticastSocket. Each UDP packet is tagged with some metadata, in particular the number of sequences. Every time my data source sends a UDP packet, this counter incrementally increments.
Here is my skeletal code:
s = java.net.MulticastSocket(50001);
s.setSoTimeout(15000);
s.setReuseAddress(1);
s.setReceiveBufferSize(32768);
s.joinGroup(java.net.InetAddress.getByName('239.255.0.4'));
p = java.net.DatagramPacket(zeros(1, 1600, 'int8'), 1600);
ii = 1;
d = cell(10000,1);
while ii < 10000
s.receive(p);
d{ii} = p.getData;
d{ii} = d{ii}(1:p.getLength);
ii = ii + 1;
end
As soon as I catch all the data, I can process it; this bit is not important.
After you catch 10,000 packets like this, I look at the sequence count and it turns out that I am missing packets. This is true; it is UDP after all, so there is no guarantee of receiving traffic. However, what is really interesting, I get only every 256th packet:
sequenceCnt =
...
56637
56893
57149
57405
57661
57917
58173
58429
58685
58941
59197
59453
...
Wireshark , . , (.. , UDP ), MATLAB/Java .
, ? Java, .