Commit 8b8e6efb authored by Sven Liefgen's avatar Sven Liefgen
Browse files

De/Serialize at the corret places

parent 57e2c3ed
Pipeline #4577 passed with stages
in 1 minute and 34 seconds
......@@ -18,7 +18,14 @@ static void gather_redundancy_packets(const PrrtBlock *block_ptr, gf *const *fec
PrrtPacket_copy_payload_to_buffer(fec[m], packet, PRRT_PACKET_REDUNDANCY_HEADER_SIZE);
// Take the data payload out of the redundancy payload and
// decode/deserialize it into the fec matrix
idx_p[m] = packet->index;
......@@ -228,6 +235,9 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno)
for(j = 0; j < r; j++) {
fec[j] = calloc(length, sizeof(gf));
// Encode/Serialize the payload and store it in the fec matrix
// A simple copy does not suffice, as the payload is send 'as is'
// over the wire. It however has to conform the protocol specification.
PrrtCoder_encode(block_ptr->coder, src, fec[j], j + k, length);
PrrtPacket *red_packet_ptr = PrrtPacket_create_redundancy_packet(0, (void *) fec[j], length, *seqno,
(uint8_t) (k + j), block_ptr->baseSequenceNumber,
......@@ -276,21 +286,21 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr)
idx_p[i] = -1;
// Store the data payload with header in the fec matrix
gather_data_packets(block_ptr, fec, idx_p);
// Store the data payload with header from the redundancy packets in the fec matrix
gather_redundancy_packets(block_ptr, fec, idx_p);
// Decode the fec matrix in place
check(PrrtCoder_decode(block_ptr->coder, fec, idx_p, length) == EXIT_SUCCESS, "Could not decode current block.");
for(j = 0; j < k; j++) {
if(idx_p[j] >= k) {
void *payload = calloc(block_ptr->largestPayloadLength, sizeof(uint8_t));
PrrtPacket_decode_payload(fec[j], PACKET_TYPE_DATA, payload, block_ptr->largestPayloadLength);
PrrtPacketDataPayload* packet_and_payload = (PrrtPacketDataPayload *) payload;
// The content of fec[j] is correctly deserialized and can be
// cast into a payload struct
PrrtPacketDataPayload* packet_and_payload = (PrrtPacketDataPayload *) fec[j];
PrrtPacket *packet = PrrtPacket_reconstruct_data_packet(packet_and_payload, j,
(prrtSequenceNumber_t) (baseSequenceNumber + j));
debug(DEBUG_BLOCK, "Reconstructed [D]: %d", packet->sequenceNumber);
if(insert_data_packet(block_ptr, packet)) {
debug(DEBUG_BLOCK, "Tried to insert unnecessary packet.");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment