gr-grnet
gr-grnet copied to clipboard
Last packet is not sent correctly
I noticed that in my source block testing, there were problems with the output file not matching the input file size. The problem appears to be on the sink side, not properly sending the last full frame packet.
It seems that instead of the last packet sending all the remaining bytes, it sends almost all bytes, but leaves out the number of bytes that the input type is configured for. For example, with a data type of "byte", if payload is set to 800, I can see a bunch of packets with length 800, ending with a 735 length packet, followed by a final packet of 1 byte instead of a final packet of 736 bytes. If the data type was set for short, the end packet would be 2 bytes length. For int and float 4 bytes and for complex, 8 bytes.
Tomorrow, I'll see if adding 1 or itemsize or something to "int lastPayloadSize = noi - ((noi / pay_len) * pay_len);" fixes this.
Perhaps this is a buffer issue? When adding itemsize to the lastPayloadSize on the push_back line, the expected bytes were just zero's and the next packet contained the expected bytes.
Found the issue.
Another if/else check is needed when sending the last packet in the "if (curPacket < (numPackets-1)) ". If the last packet size is 0, it sends a 0 byte packet instead of sending the payload size. So need to add a check that if lastPacketSize is > 0, use size of lastPacketSize, otherwise use sizeof d_payloadsize so the last frame is full and not zeros.