I'm working on teleoperating remote-site robot via network.
I'm starting from scratch and I'm thinking about command packet to be sent to the robot.
I want to use simple protocol.
[LENGTH] [HEADER] [BODY]
LENGTH is bytes of [HEADER+BODY].
HEADER will include type of command, current mode etc...
BODY will include real data(goal position, velocity, torque etc..)
My question is this.
If I use this protocol, first I get the length of the packet and extract the data from the stream based on the length information.
But let's think about the case of "error in length data".
packet stream...
[10] [5Bytes] [10Bytes] | [15] [5Bytes] [10Bytes] | [15] [5Bytes] [10Bytes] ...
There is length error in first packet.
I think this error can break every packets following it.
I'll use UDP for command packet, and it doesn't guarantee that data will be received correctly.
I think this case is possible.
Is it really happens?
If it is, is there any solution for this?