Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
8b8e6efb
Commit
8b8e6efb
authored
Aug 24, 2020
by
Sven Liefgen
Browse files
De/Serialize at the corret places
parent
57e2c3ed
Pipeline
#4577
passed with stages
in 1 minute and 34 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
prrt/proto/types/block.c
View file @
8b8e6efb
...
@@ -18,7 +18,14 @@ static void gather_redundancy_packets(const PrrtBlock *block_ptr, gf *const *fec
...
@@ -18,7 +18,14 @@ static void gather_redundancy_packets(const PrrtBlock *block_ptr, gf *const *fec
m
++
;
m
++
;
}
}
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
PrrtPacket_decode_payload
(
packet
->
payload
+
PRRT_PACKET_REDUNDANCY_HEADER_SIZE
,
PACKET_TYPE_DATA
,
fec
[
m
],
packet
->
payloadLength
);
idx_p
[
m
]
=
packet
->
index
;
idx_p
[
m
]
=
packet
->
index
;
PrrtPacket_destroy
(
packet
);
PrrtPacket_destroy
(
packet
);
}
}
...
@@ -228,6 +235,9 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno)
...
@@ -228,6 +235,9 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno)
for
(
j
=
0
;
j
<
r
;
j
++
)
{
for
(
j
=
0
;
j
<
r
;
j
++
)
{
fec
[
j
]
=
calloc
(
length
,
sizeof
(
gf
));
fec
[
j
]
=
calloc
(
length
,
sizeof
(
gf
));
check_mem
(
fec
[
j
]);
check_mem
(
fec
[
j
]);
// 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
);
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
,
PrrtPacket
*
red_packet_ptr
=
PrrtPacket_create_redundancy_packet
(
0
,
(
void
*
)
fec
[
j
],
length
,
*
seqno
,
(
uint8_t
)
(
k
+
j
),
block_ptr
->
baseSequenceNumber
,
(
uint8_t
)
(
k
+
j
),
block_ptr
->
baseSequenceNumber
,
...
@@ -276,21 +286,21 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr)
...
@@ -276,21 +286,21 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr)
idx_p
[
i
]
=
-
1
;
idx_p
[
i
]
=
-
1
;
}
}
// Store the data payload with header in the fec matrix
gather_data_packets
(
block_ptr
,
fec
,
idx_p
);
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
);
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."
);
check
(
PrrtCoder_decode
(
block_ptr
->
coder
,
fec
,
idx_p
,
length
)
==
EXIT_SUCCESS
,
"Could not decode current block."
);
for
(
j
=
0
;
j
<
k
;
j
++
)
{
for
(
j
=
0
;
j
<
k
;
j
++
)
{
if
(
idx_p
[
j
]
>=
k
)
{
if
(
idx_p
[
j
]
>=
k
)
{
void
*
payload
=
calloc
(
block_ptr
->
largestPayloadLength
,
sizeof
(
uint8_t
));
// The content of fec[j] is correctly deserialized and can be
check_mem
(
payload
);
// cast into a payload struct
PrrtPacket_decode_payload
(
fec
[
j
],
PACKET_TYPE_DATA
,
payload
,
block_ptr
->
largestPayloadLength
);
PrrtPacketDataPayload
*
packet_and_payload
=
(
PrrtPacketDataPayload
*
)
fec
[
j
];
PrrtPacketDataPayload
*
packet_and_payload
=
(
PrrtPacketDataPayload
*
)
payload
;
PrrtPacket
*
packet
=
PrrtPacket_reconstruct_data_packet
(
packet_and_payload
,
j
,
PrrtPacket
*
packet
=
PrrtPacket_reconstruct_data_packet
(
packet_and_payload
,
j
,
(
prrtSequenceNumber_t
)
(
baseSequenceNumber
+
j
));
(
prrtSequenceNumber_t
)
(
baseSequenceNumber
+
j
));
free
(
payload
);
debug
(
DEBUG_BLOCK
,
"Reconstructed [D]: %d"
,
packet
->
sequenceNumber
);
debug
(
DEBUG_BLOCK
,
"Reconstructed [D]: %d"
,
packet
->
sequenceNumber
);
if
(
insert_data_packet
(
block_ptr
,
packet
))
{
if
(
insert_data_packet
(
block_ptr
,
packet
))
{
debug
(
DEBUG_BLOCK
,
"Tried to insert unnecessary packet."
);
debug
(
DEBUG_BLOCK
,
"Tried to insert unnecessary packet."
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment