Commit 293d07ce authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Introduce custom typedefs for prrt types.

parent c3b549f4
...@@ -63,7 +63,7 @@ cdef extern from "prrt/block.h": ...@@ -63,7 +63,7 @@ cdef extern from "prrt/block.h":
uint32_t redundancy_count uint32_t redundancy_count
PrrtCodingParams coding_params PrrtCodingParams coding_params
uint32_t largest_data_length uint32_t largest_data_length
uint16_t base_seqno uint16_t baseSequenceNumber
List* data_blocks List* data_blocks
List* redundancy_blocks List* redundancy_blocks
uint8_t is_coded uint8_t is_coded
...@@ -74,9 +74,9 @@ cdef extern from "prrt/packet.h": ...@@ -74,9 +74,9 @@ cdef extern from "prrt/packet.h":
cdef struct prrtPacket: cdef struct prrtPacket:
uint8_t type_priority; uint8_t type_priority;
uint8_t index; uint8_t index;
uint16_t seqno; uint16_t sequenceNumber;
void* payload; void* payload;
uint32_t payload_len; uint32_t payloadLength;
ctypedef prrtPacket PrrtPacket ctypedef prrtPacket PrrtPacket
...@@ -121,7 +121,7 @@ cdef extern from "prrt/socket.h": ...@@ -121,7 +121,7 @@ cdef extern from "prrt/socket.h":
ctypedef prrtSocket PrrtSocket ctypedef prrtSocket PrrtSocket
cdef PrrtSocket* PrrtSocket_create(bint is_sender) cdef PrrtSocket* PrrtSocket_create(bint isSender)
bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port) bint PrrtSocket_bind(PrrtSocket *sock_ptr, const_char *ipAddress, const uint16_t port)
int PrrtSocket_close(const PrrtSocket *sock_ptr) int PrrtSocket_close(const PrrtSocket *sock_ptr)
int PrrtSocket_connect(PrrtSocket *sock_ptr, const_char *host, const uint16_t port) int PrrtSocket_connect(PrrtSocket *sock_ptr, const_char *host, const uint16_t port)
......
...@@ -3,7 +3,7 @@ cimport cprrt ...@@ -3,7 +3,7 @@ cimport cprrt
cdef extern from "prrt/stores/forwardPacketTable.c": cdef extern from "prrt/stores/forwardPacketTable.c":
int PrrtForwardPacketTable_create(cprrt.PrrtForwardPacketTable* fpt_prt); int PrrtForwardPacketTable_create(cprrt.PrrtForwardPacketTable* fpt_prt);
int PrrtForwardPacketTable_test_set_is_number_relevant(cprrt.PrrtForwardPacketTable *fpt_ptr, uint16_t seqno); int PrrtForwardPacketTable_test_set_is_number_relevant(cprrt.PrrtForwardPacketTable *fpt_ptr, uint16_t sequenceNumber);
int PrrtForwardPacketTable_test_is_block_relevant(cprrt.PrrtForwardPacketTable * forwardPacketTable, uint16_t start, uint16_t length); int PrrtForwardPacketTable_test_is_block_relevant(cprrt.PrrtForwardPacketTable * forwardPacketTable, uint16_t start, uint16_t length);
int PrrtForwardPacketTable_destroy(cprrt.PrrtForwardPacketTable* fpt_prt); int PrrtForwardPacketTable_destroy(cprrt.PrrtForwardPacketTable* fpt_prt);
...@@ -42,7 +42,7 @@ cdef extern from "prrt/packet.c": ...@@ -42,7 +42,7 @@ cdef extern from "prrt/packet.c":
int PrrtPacket_print(cprrt.PrrtPacket *packet_ptr) int PrrtPacket_print(cprrt.PrrtPacket *packet_ptr)
cdef extern from "prrt/socket.c": cdef extern from "prrt/socket.c":
cprrt.PrrtSocket* PrrtSocket_create(uint16_t port, uint8_t is_sender) cprrt.PrrtSocket* PrrtSocket_create(uint16_t port, uint8_t isSender)
cdef extern from "util/bptree.c": cdef extern from "util/bptree.c":
cprrt.BPTreeNode *BPTree_insert(cprrt.BPTreeNode *root, int key, void *value) cprrt.BPTreeNode *BPTree_insert(cprrt.BPTreeNode *root, int key, void *value)
......
...@@ -61,7 +61,7 @@ void PrrtBlock_destroy(PrrtBlock *mblock) ...@@ -61,7 +61,7 @@ void PrrtBlock_destroy(PrrtBlock *mblock)
free(mblock); free(mblock);
} }
PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, uint16_t base_seqno) PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, prrtSequenceNumber_t baseSequenceNumber)
{ {
PrrtBlock *block = calloc(1, sizeof(PrrtBlock)); PrrtBlock *block = calloc(1, sizeof(PrrtBlock));
check_mem(block); check_mem(block);
...@@ -69,7 +69,7 @@ PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, uint16_t base_seqno) ...@@ -69,7 +69,7 @@ PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, uint16_t base_seqno)
block->codingParams = *cpar; block->codingParams = *cpar;
block->dataPackets = List_create(); block->dataPackets = List_create();
block->redundancyPackets = List_create(); block->redundancyPackets = List_create();
block->baseSequenceNumber = base_seqno; block->baseSequenceNumber = baseSequenceNumber;
block->largestDataLength = 0; block->largestDataLength = 0;
return block; return block;
...@@ -84,15 +84,15 @@ bool PrrtBlock_insert_data_packet(PrrtBlock *prrtBlock, const PrrtPacket *prrtPa ...@@ -84,15 +84,15 @@ bool PrrtBlock_insert_data_packet(PrrtBlock *prrtBlock, const PrrtPacket *prrtPa
bool found = false; bool found = false;
LIST_FOREACH(prrtBlock->dataPackets, first, next, cur) { LIST_FOREACH(prrtBlock->dataPackets, first, next, cur) {
PrrtPacket *pkt = cur->value; PrrtPacket *pkt = cur->value;
if(pkt->seqno == prrtPacket->seqno) { if(pkt->sequenceNumber == prrtPacket->sequenceNumber) {
found = true; found = true;
} }
} }
if(found == false) { if(found == false) {
List_push(prrtBlock->dataPackets, prrtPacket); List_push(prrtBlock->dataPackets, prrtPacket);
prrtBlock->largestDataLength = (uint32_t) MAX(prrtBlock->largestDataLength, prrtBlock->largestDataLength = (prrtPacketLength_t) MAX(prrtBlock->largestDataLength,
prrtPacket->payload_len - PRRT_PACKET_DATA_HEADER_SIZE); prrtPacket->payloadLength - PRRT_PACKET_DATA_HEADER_SIZE);
return true; return true;
} else { } else {
return false; return false;
...@@ -104,15 +104,15 @@ bool PrrtBlock_insert_redundancy_packet(PrrtBlock *block_ptr, const PrrtPacket * ...@@ -104,15 +104,15 @@ bool PrrtBlock_insert_redundancy_packet(PrrtBlock *block_ptr, const PrrtPacket *
bool found = false; bool found = false;
LIST_FOREACH(block_ptr->redundancyPackets, first, next, cur) { LIST_FOREACH(block_ptr->redundancyPackets, first, next, cur) {
PrrtPacket *pkt = cur->value; PrrtPacket *pkt = cur->value;
if(pkt->seqno == ptr->seqno) { if(pkt->sequenceNumber == ptr->sequenceNumber) {
found = true; found = true;
} }
} }
if(found == false) { if(found == false) {
List_push(block_ptr->redundancyPackets, ptr); List_push(block_ptr->redundancyPackets, ptr);
block_ptr->largestDataLength = (uint32_t) MAX(block_ptr->largestDataLength, block_ptr->largestDataLength = (prrtPacketLength_t) MAX(block_ptr->largestDataLength,
ptr->payload_len - PRRT_PACKET_REDUNDANCY_HEADER_SIZE); ptr->payloadLength - PRRT_PACKET_REDUNDANCY_HEADER_SIZE);
return true; return true;
} else { } else {
return false; return false;
...@@ -134,14 +134,14 @@ PrrtPacket *PrrtBlock_get_first_data(PrrtBlock *block_ptr) ...@@ -134,14 +134,14 @@ PrrtPacket *PrrtBlock_get_first_data(PrrtBlock *block_ptr)
return List_shift(block_ptr->dataPackets); return List_shift(block_ptr->dataPackets);
} }
void PrrtBlock_encode(PrrtBlock *block_ptr, uint16_t *seqno) void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno)
{ {
int j = 0; int j = 0;
uint8_t k = block_ptr->codingParams.k; uint8_t k = block_ptr->codingParams.k;
uint8_t n = block_ptr->codingParams.n; uint8_t n = block_ptr->codingParams.n;
uint8_t r = block_ptr->codingParams.r; uint8_t r = block_ptr->codingParams.r;
uint16_t baseSequenceNumber = block_ptr->baseSequenceNumber; prrtSequenceNumber_t baseSequenceNumber = block_ptr->baseSequenceNumber;
uint32_t length = block_ptr->largestDataLength; prrtPacketLength_t length = block_ptr->largestDataLength;
PrrtCoder *coder = NULL; PrrtCoder *coder = NULL;
...@@ -154,7 +154,7 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, uint16_t *seqno) ...@@ -154,7 +154,7 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, uint16_t *seqno)
src[j] = calloc(length, sizeof(gf)); src[j] = calloc(length, sizeof(gf));
check_mem(src[j]); check_mem(src[j]);
PrrtPacket *pkt = cur->value; PrrtPacket *pkt = cur->value;
pkt->index = (uint8_t) ((pkt->seqno - baseSequenceNumber) % SEQNO_SPACE); pkt->index = (uint8_t) ((pkt->sequenceNumber - baseSequenceNumber) % SEQNO_SPACE);
PrrtPacket_copy_payload_to_buffer(src[j], pkt, PRRT_PACKET_DATA_HEADER_SIZE); PrrtPacket_copy_payload_to_buffer(src[j], pkt, PRRT_PACKET_DATA_HEADER_SIZE);
j++; j++;
} }
...@@ -168,7 +168,7 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, uint16_t *seqno) ...@@ -168,7 +168,7 @@ void PrrtBlock_encode(PrrtBlock *block_ptr, uint16_t *seqno)
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,
block_ptr->codingParams); block_ptr->codingParams);
*seqno = (uint16_t) ((*seqno + 1) % SEQNO_SPACE); *seqno = (prrtSequenceNumber_t) ((*seqno + 1) % SEQNO_SPACE);
PrrtBlock_insert_redundancy_packet(block_ptr, red_packet_ptr); PrrtBlock_insert_redundancy_packet(block_ptr, red_packet_ptr);
} }
...@@ -193,8 +193,8 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr) ...@@ -193,8 +193,8 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr)
int *idx_p = NULL; int *idx_p = NULL;
uint8_t n = block_ptr->codingParams.n; uint8_t n = block_ptr->codingParams.n;
uint8_t k = block_ptr->codingParams.k; uint8_t k = block_ptr->codingParams.k;
uint16_t baseSequenceNumber = block_ptr->baseSequenceNumber; prrtSequenceNumber_t baseSequenceNumber = block_ptr->baseSequenceNumber;
uint32_t length = block_ptr->largestDataLength; prrtPacketLength_t length = block_ptr->largestDataLength;
PrrtCoder *coder = NULL; PrrtCoder *coder = NULL;
...@@ -219,7 +219,7 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr) ...@@ -219,7 +219,7 @@ bool PrrtBlock_decode(PrrtBlock *block_ptr)
for(j = 0; j < k; j++) { for(j = 0; j < k; j++) {
if(idx_p[j] >= k) { if(idx_p[j] >= k) {
PrrtPacket *packet = PrrtPacket_create_data_packet(0, fec[j], length, (uint16_t) (baseSequenceNumber + j)); PrrtPacket *packet = PrrtPacket_create_data_packet(0, fec[j], length, (prrtSequenceNumber_t) (baseSequenceNumber + j));
if(PrrtBlock_insert_data_packet(block_ptr, packet) == false) { if(PrrtBlock_insert_data_packet(block_ptr, packet) == false) {
debug("Tried to insert unnecessary packet."); debug("Tried to insert unnecessary packet.");
PrrtPacket_destroy(packet); PrrtPacket_destroy(packet);
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
typedef struct prrtBlock { typedef struct prrtBlock {
PrrtCodingParams codingParams; PrrtCodingParams codingParams;
uint32_t largestDataLength; prrtPacketLength_t largestDataLength;
uint16_t baseSequenceNumber; prrtSequenceNumber_t baseSequenceNumber;
List*dataPackets; List*dataPackets;
List*redundancyPackets; List*redundancyPackets;
bool isCoded; bool isCoded;
...@@ -18,7 +18,7 @@ typedef struct prrtBlock { ...@@ -18,7 +18,7 @@ typedef struct prrtBlock {
/** /**
* Allocate space for a block. * Allocate space for a block.
*/ */
PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, uint16_t base_seqno); PrrtBlock * PrrtBlock_create(const PrrtCodingParams *cpar, prrtSequenceNumber_t baseSequenceNumber);
/** /**
* Frees the PrrtBlock data structure. * Frees the PrrtBlock data structure.
...@@ -33,7 +33,7 @@ bool PrrtBlock_decode_ready(const PrrtBlock *block_ptr); ...@@ -33,7 +33,7 @@ bool PrrtBlock_decode_ready(const PrrtBlock *block_ptr);
PrrtPacket *PrrtBlock_get_first_data(PrrtBlock *block_ptr); PrrtPacket *PrrtBlock_get_first_data(PrrtBlock *block_ptr);
void PrrtBlock_encode(PrrtBlock *block_ptr, uint16_t *seqno); void PrrtBlock_encode(PrrtBlock *block_ptr, prrtSequenceNumber_t *seqno);
bool PrrtBlock_decode(PrrtBlock *block_ptr); bool PrrtBlock_decode(PrrtBlock *block_ptr);
PrrtPacket *PrrtBlock_get_first_red_data(PrrtBlock *block_ptr); PrrtPacket *PrrtBlock_get_first_red_data(PrrtBlock *block_ptr);
......
...@@ -16,12 +16,12 @@ void PrrtChannelStateInformation_init(PrrtChannelStateInformation *csi) ...@@ -16,12 +16,12 @@ void PrrtChannelStateInformation_init(PrrtChannelStateInformation *csi)
PERROR("Should not happen.%s",""); PERROR("Should not happen.%s","");
} }
void PrrtChannelStateInformation_update_rtt(PrrtChannelStateInformation *csi, uint32_t rtt) void PrrtChannelStateInformation_update_rtt(PrrtChannelStateInformation *csi, prrtTimedelta_t rtt)
{ {
int32_t delta = rtt - csi->rttMean; int32_t delta = rtt - csi->rttMean;
// TODO: ensure that there are no arithemtic problems via rounding etc. // TODO: ensure that there are no arithemtic problems via rounding etc.
csi->rttMean = (uint16_t) (csi->rttMean + RRT_ALPHA * delta); csi->rttMean = (prrtTimedelta_t) (csi->rttMean + RRT_ALPHA * delta);
csi->rttDev = (uint16_t) (csi->rttDev + RRT_ALPHA * (labs(delta) - csi->rttDev)); csi->rttDev = (prrtTimedelta_t) (csi->rttDev + RRT_ALPHA * (labs(delta) - csi->rttDev));
} }
void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi) void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi)
......
#ifndef PRRT_CHANNELSTATEINFORMATION_H #ifndef PRRT_CHANNELSTATEINFORMATION_H
#define PRRT_CHANNELSTATEINFORMATION_H #define PRRT_CHANNELSTATEINFORMATION_H
#include <stdint.h> #include "packet.h"
typedef struct prrtChannelStateInformation { typedef struct prrtChannelStateInformation {
uint16_t rttMean; prrtTimedelta_t rttMean;
uint16_t rttDev; prrtTimedelta_t rttDev;
} PrrtChannelStateInformation; } PrrtChannelStateInformation;
void PrrtChannelStateInformation_init(PrrtChannelStateInformation* csi); void PrrtChannelStateInformation_init(PrrtChannelStateInformation* csi);
void PrrtChannelStateInformation_update_rtt(PrrtChannelStateInformation* csi, uint32_t rtt); void PrrtChannelStateInformation_update_rtt(PrrtChannelStateInformation* csi, prrtTimedelta_t rtt);
void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi); void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi);
......
#include <sys/time.h> #include <sys/time.h>
#include <stddef.h> #include <stddef.h>
#include "clock.h" #include "clock.h"
#include "packet.h"
uint32_t PrrtClock_get_current_time(void) { prrtTimestamp_t PrrtClock_get_current_time(void) {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
uint32_t time_in_micros = (uint32_t) (1000000 * tv.tv_sec + tv.tv_usec); return (prrtTimestamp_t) (1000000 * tv.tv_sec + tv.tv_usec);
return time_in_micros;
} }
#ifndef PRRT_CLOCK_H #ifndef PRRT_CLOCK_H
#define PRRT_CLOCK_H #define PRRT_CLOCK_H
#include <stdint.h> #include "packet.h"
uint32_t PrrtClock_get_current_time(void); prrtTimestamp_t PrrtClock_get_current_time(void);
#endif //PRRT_CLOCK_H #endif //PRRT_CLOCK_H
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <pthread.h> #include <pthread.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
typedef struct prrtCodingParams { typedef struct prrtCodingParams {
pthread_mutex_t lock; pthread_mutex_t lock;
......
This diff is collapsed.
#ifndef PRRT_FRAME_H #ifndef PRRT_FRAME_H
#define PRRT_FRAME_H #define PRRT_FRAME_H
// CREATE: PRRT_PACKET
// ENCODE: PRRT_PACKET -> BYTES
// DECODE: BYTES -> PRRT_PACKET
// DESTROY:
#include <stdint.h> #include <stdint.h>
#include "codingParams.h" #include "codingParams.h"
#include <stdbool.h> #include <stdbool.h>
#define PACKET_TYPE_DATA 0 typedef enum {
#define PACKET_TYPE_REPETITION 1 PACKET_TYPE_DATA = 0,
#define PACKET_TYPE_REDUNDANCY 2 PACKET_TYPE_REPETITION = 1,
#define PACKET_TYPE_FEEDBACK 3 PACKET_TYPE_REDUNDANCY = 2,
#define PACKET_TYPE_PRE_REDUNDANCY 4 PACKET_TYPE_FEEDBACK = 3,
#define PACKET_TYPE_CHANNEL_FEEDBACK 5 PACKET_TYPE_PRESENT_REDUNDANCY = 4,
PACKET_TYPE_CHANNEL_FEEDBACK = 5
} prrtPacketType_t;
typedef uint16_t prrtSequenceNumber_t;
typedef uint8_t prrtIndex_t;
typedef uint32_t prrtTimestamp_t;
typedef uint32_t prrtTimedelta_t;
typedef uint32_t prrtPacketLength_t;
typedef struct prrtIncompleteBlock {
prrtSequenceNumber_t sequenceNumberBase;
uint16_t repairCycleIndex;
} PrrtIncompleteBlock;
typedef struct prrtPacket { typedef struct prrtPacket {
uint8_t type_priority; uint8_t type_priority;
uint8_t index; prrtIndex_t index;
uint16_t seqno; prrtSequenceNumber_t sequenceNumber;
void* payload; void *payload;
uint32_t payload_len; prrtPacketLength_t payloadLength;
} PrrtPacket; } PrrtPacket;
#define PRRT_PACKET_GENERAL_HEADER_SIZE 8 #define PRRT_PACKET_GENERAL_HEADER_SIZE 8
#define PRRT_PACKET_ENCODED_GENERAL_HEADER_LENGTH 4 #define PRRT_PACKET_ENCODED_GENERAL_HEADER_LENGTH 4
...@@ -30,57 +38,68 @@ typedef struct prrtPacket { ...@@ -30,57 +38,68 @@ typedef struct prrtPacket {
#define SEQNO_SPACE UINT16_MAX // 2**16 as seqno is uint16_t #define SEQNO_SPACE UINT16_MAX // 2**16 as seqno is uint16_t
typedef struct prrtPacketDataPayload { typedef struct prrtPacketDataPayload {
uint32_t timestamp; prrtTimestamp_t timestamp;
uint16_t group_round_trip_time; prrtTimedelta_t groupRTT_us;
uint16_t packet_timeout; prrtTimedelta_t packetTimeout_us;
uint16_t decoding_timeout; prrtTimedelta_t decodingTimeout_us;
uint16_t feedback_timeout; prrtTimedelta_t feedbackTimeout_us;
} PrrtPacketDataPayload; } PrrtPacketDataPayload;
#define PRRT_PACKET_DATA_HEADER_SIZE sizeof(PrrtPacketDataPayload) #define PRRT_PACKET_DATA_HEADER_SIZE sizeof(PrrtPacketDataPayload)
typedef struct prrtPacketRedundancyPayload { typedef struct prrtPacketRedundancyPayload {
uint16_t base_seqno; prrtSequenceNumber_t baseSequenceNumber;
uint8_t n; uint8_t n;
uint8_t k; uint8_t k;
} PrrtPacketRedundancyPayload; } PrrtPacketRedundancyPayload;
#define PRRT_PACKET_REDUNDANCY_HEADER_SIZE sizeof(PrrtPacketRedundancyPayload) #define PRRT_PACKET_REDUNDANCY_HEADER_SIZE sizeof(PrrtPacketRedundancyPayload)
typedef struct prrtPacketFeedbackPayload { typedef struct prrtPacketFeedbackPayload {
uint32_t receiver_addr; uint32_t receiverAddress;
uint32_t group_round_trip_time; prrtTimedelta_t groupRTT_us;
uint32_t forward_trip_timestamp; prrtTimestamp_t forwardTripTimestamp_us;
uint32_t packet_loss_rate; prrtSequenceNumber_t erasureCount;
uint16_t gap; prrtSequenceNumber_t packetCount;
uint16_t ngap; prrtSequenceNumber_t gapLength;
uint16_t burst; prrtSequenceNumber_t gapCount;
uint16_t nburst; prrtSequenceNumber_t burstLength;
uint32_t bandwidth_estimate; prrtSequenceNumber_t burstCount;
uint32_t buffer_feedback; uint32_t bandwidthEstimate;
PrrtIncompleteBlock *incompleteBlocks;
} PrrtPacketFeedbackPayload; } PrrtPacketFeedbackPayload;
#define PRRT_PACKET_FEEDBACK_HEADER_SIZE sizeof(PrrtPacketFeedbackPayload) #define PRRT_PACKET_FEEDBACK_HEADER_SIZE sizeof(PrrtPacketFeedbackPayload) - sizeof(PrrtIncompleteBlock*)
prrtPacketType_t PrrtPacket_type(PrrtPacket *packet_ptr);
uint8_t PrrtPacket_type(PrrtPacket *packet_ptr);
uint8_t PrrtPacket_priority(PrrtPacket *packet_ptr); uint8_t PrrtPacket_priority(PrrtPacket *packet_ptr);
uint16_t PrrtPacket_size(PrrtPacket *packet_ptr);
prrtPacketLength_t PrrtPacket_size(PrrtPacket *packet_ptr);
int PrrtPacket_print(PrrtPacket *packet_ptr); int PrrtPacket_print(PrrtPacket *packet_ptr);
PrrtPacket *PrrtPacket_copy(PrrtPacket *original); PrrtPacket *PrrtPacket_copy(PrrtPacket *original);
PrrtPacket * PrrtPacket_create_data_packet(uint8_t priority, const void *payloadPointer, uint32_t payloadLength, uint16_t sequenceNumber); PrrtPacket *PrrtPacket_create_data_packet(uint8_t priority, const void *payloadPointer,
prrtPacketLength_t payloadLength, prrtSequenceNumber_t sequenceNumber);
PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, uint16_t sequenceNumber, PrrtPacket *PrrtPacket_create_feedback_packet(uint8_t priority, uint8_t index, prrtSequenceNumber_t sequenceNumber,
uint32_t roundTripTime, uint32_t packetLossRate, uint16_t gap, prrtTimedelta_t roundTripTime, prrtSequenceNumber_t gapLength,
uint16_t ngap, uint16_t burst, uint16_t nburst, uint32_t bandwidth, prrtSequenceNumber_t gapCount, prrtSequenceNumber_t burstLength,
uint32_t bufferFeedback, uint32_t receiverAddr); prrtSequenceNumber_t burstCount, uint32_t bandwidth,
uint32_t receiverAddr);
PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadPointer, uint32_t payloadLength, PrrtPacket *PrrtPacket_create_redundancy_packet(uint8_t priority, void *payloadPointer,
uint16_t sequenceNumber, uint8_t index, uint16_t baseSequenceNumber, PrrtCodingParams codingParams); prrtPacketLength_t payloadLength,
prrtSequenceNumber_t sequenceNumber, uint8_t index,
prrtSequenceNumber_t baseSequenceNumber, PrrtCodingParams codingParams);
bool PrrtPacket_decode(void *srcBuffer, uint16_t srcBufferSize, PrrtPacket *targetPacket); bool PrrtPacket_decode(void *srcBuffer, uint16_t srcBufferSize, PrrtPacket *targetPacket);
bool PrrtPacket_encode(void *buf_ptr, uint16_t buf_size, PrrtPacket *packet_ptr); bool PrrtPacket_encode(void *buf_ptr, uint16_t buf_size, PrrtPacket *packet_ptr);
int PrrtPacket_destroy(PrrtPacket *packet); int PrrtPacket_destroy(PrrtPacket *packet);
#define PrrtPacket_copy_payload_to_buffer(dst, packet, header_size) memcpy(dst, packet->payload + header_size, packet->payload_len - header_size); #define PrrtPacket_copy_payload_to_buffer(dst, packet, header_size) memcpy(dst, packet->payload + header_size, packet->payloadLength - header_size);
#define PrrtPacket_copy_buffer_to_payload(packet, src, header_size) memcpy(packet->payload + header_size, src, packet->payload_len - header_size); #define PrrtPacket_copy_buffer_to_payload(packet, src, header_size) memcpy(packet->payload + header_size, src, packet->payloadLength - header_size);
#define PrrtPacket_get_data_timestamp(packet) ((PrrtPacketDataPayload*) packet->payload)->timestamp; #define PrrtPacket_get_data_timestamp(packet) ((PrrtPacketDataPayload*) packet->payload)->timestamp;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "../socket.h" #include "../socket.h"
#include "dataReceiver.h" #include "dataReceiver.h"
void retrieve_data_blocks(PrrtSocket *sock_ptr, uint16_t base_seqno, uint8_t k, const PrrtBlock *block) void retrieve_data_blocks(PrrtSocket *sock_ptr, prrtSequenceNumber_t base_seqno, uint8_t k, const PrrtBlock *block)
{ {
List *res = List_create(); List *res = List_create();
BPTree_get_range(sock_ptr->dataStore, res, base_seqno, base_seqno + k - 1); BPTree_get_range(sock_ptr->dataStore, res, base_seqno, base_seqno + k - 1);
...@@ -17,20 +17,20 @@ void retrieve_data_blocks(PrrtSocket *sock_ptr, uint16_t base_seqno, uint8_t k, ...@@ -17,20 +17,20 @@ void retrieve_data_blocks(PrrtSocket *sock_ptr, uint16_t base_seqno, uint8_t k,
LIST_FOREACH(res, first, next, cur) { LIST_FOREACH(res, first, next, cur) {
PrrtPacket *packetPtr = cur->value; PrrtPacket *packetPtr = cur->value;
check(PrrtBlock_insert_data_packet((PrrtBlock *) block, packetPtr), "Insert failed!") check(PrrtBlock_insert_data_packet((PrrtBlock *) block, packetPtr), "Insert failed!")
sock_ptr->dataStore = BPTree_delete(sock_ptr->dataStore, packetPtr->seqno); sock_ptr->dataStore = BPTree_delete(sock_ptr->dataStore, packetPtr->sequenceNumber);
} }
error: error:
List_destroy(res); List_destroy(res);
} }
void decode_block(PrrtSocket *sock_ptr, PrrtBlock *block, uint16_t base_seqno) void decode_block(PrrtSocket *sock_ptr, PrrtBlock *block, prrtSequenceNumber_t base_seqno)
{ {
if(block != NULL && PrrtBlock_decode_ready(block)) { if(block != NULL && PrrtBlock_decode_ready(block)) {
check(PrrtBlock_decode(block), "Decoding failed"); check(PrrtBlock_decode(block), "Decoding failed");
while(List_count(block->dataPackets) > 0) { while(List_count(block->dataPackets) > 0) {
PrrtPacket *pkt = List_shift(block->dataPackets); PrrtPacket *pkt = List_shift(block->dataPackets);
if(PrrtForwardPacketTable_test_set_is_number_relevant(sock_ptr->forwardPacketTable, pkt->seqno)) { if(PrrtForwardPacketTable_test_set_is_number_relevant(sock_ptr->forwardPacketTable, pkt->sequenceNumber)) {
check(pthread_mutex_lock(&sock_ptr->inQueueFilledMutex) == 0, "Lock failed."); check(pthread_mutex_lock(&sock_ptr->inQueueFilledMutex) == 0, "Lock failed.");
List_push(sock_ptr->inQueue, pkt); List_push(sock_ptr->inQueue, pkt);
check(pthread_cond_signal(&sock_ptr->inQueueFilledCv) == 0, "Signal failed."); check(pthread_cond_signal(&sock_ptr->inQueueFilledCv) == 0, "Signal failed.");
...@@ -62,15 +62,16 @@ bool send_feedback(const PrrtSocket *sock_ptr, struct sockaddr_in remote) ...@@ -62,15 +62,16 @@ bool send_feedback(const PrrtSocket *sock_ptr, struct sockaddr_in remote)
hp = gethostbyname(remote_host); hp = gethostbyname(remote_host);