Since UDP is a connection less protocol so we know there is no guarantee that data will be received by a receiver. But if the datagram is received, is it possible that data is partly /fully corrupt ?
UDP header also contains CRC, so this makes me feel that in case datagram is received the data would be reliable ? Is that correct or not ?
To more elaborate the problem I send the data from Java udp server like
// Sending in Java
InetAddress group = InetAddress.getByName("230.0.0.1");
//buf is a String.getBytes();
DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446);
//socket is DatagramSocket in Java
socket.send(packet);
and get data in C# client like this
// client is UdpClient of C#
Byte[] data = client.Receive(ref localEp);
strData = Encoding.ASCII.GetString(data);
I am not manipulating CRC myself , at the receiver end I get the same data that was sent in buf, SO how do I check the CRC here, given I have an array of byte data.. ? or assume it would be correct (I can live with those extreme cases where CRC would match ie CRC and data are magically corrupt)
You can trust that the datagram is intact if its checksum (not technically a CRC) is correct, but that doesn’t mean you can trust the data. There’s nothing magic about the checksum formula, so a process that altered the data could merely recalculate the checksum and you’d never know.