Loading prrt/prrt.pyx +78 −4 Original line number Diff line number Diff line Loading @@ -146,8 +146,33 @@ class ApplicationParameters: self.maxResidualLossRate) def __str__(self): return "({},{},{})".format(self.maxLatency, self.maxLatency) return "({},{})".format(self.maxLatency, self.maxResidualLossRate) class PrrtSystemParameters: def __init__(self, block_coding_delay, redundancy_packet_transmission_delay, processing_delay, packet_loss_detection_delay): self.block_coding_delay = block_coding_delay self.redundancy_packet_transmission_delay = redundancy_packet_transmission_delay self.processing_delay = processing_delay self.packet_loss_detection_delay = packet_loss_detection_delay def __repr__(self): return "PrrtSystemParameters(block_coding_delay={}," \ "redundancy_packet_transmission_delay={}," \ "processing_delay={}," \ "packet_loss_detection_delay={})".format(self.block_coding_delay, self.redundancy_packet_transmission_delay, self.processing_delay, self.packet_loss_detection_delay) def __str__(self): return "({},{},{},{})".format(self.block_coding_delay, self.redundancy_packet_transmission_delay, self.processing_delay, self.packet_loss_detection_delay) class PrrtCodingConfiguration: p_e = 0.0 Loading Loading @@ -175,7 +200,6 @@ class PrrtCodingConfiguration: # TODO # def __eq__() # TODO # Calculate the redundancy information this coding configuration causes, given a certain channel. def sum_error_prob_over_sent_packets(self, sent_packets_item): error_prob = 0 Loading @@ -196,7 +220,32 @@ class PrrtCodingConfiguration: # TODO # Check if it is able to fulfill application parameters given channel parameters. # def is_valid_for(applicationParameters, channelParameters) def hypergeometric_distribution(self, n, k, i, j): return (comb(k, i) * comb(n - k, j - i)) / comb(n, j) def is_valid_for(self, prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters): if (self.is_maximum_latency_fulfilled(prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters) and self.is_maximum_loss_fulfilled(prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters)): return True def is_maximum_latency_fulfilled(self, prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters): fec_delay = prrtSystemParameters.block_coding_delay + self.n_p[0] * prrtSystemParameters.redundancy_packet_transmission_delay + \ (prrtChannelParameters.rtt_prop_fwd + prrtSystemParameters.processing_delay) / 2 + \ prrtSystemParameters.packet_loss_detection_delay req_delay_list = list(map(lambda c : prrtChannelParameters.rtt_prop_fwd + np.dot(self.n_p[c], prrtSystemParameters.redundancy_packet_transmission_delay) + prrtSystemParameters.processing_delay)) if (fec_delay + np.dot(self.len(self.n_p), req_delay_list) <= prrtApplicationParameters.maxLatency): return True def is_maximum_loss_fulfilled(self, prrtApplicationParameters): total_packet_erasure = 0 for i in range(1, self.k): for j in range(max(self.n - self.k + 1, i), self.n - self.k + i): packet_erasure_at_i = i * self.hypergeometric_distribution(self.n, self.k, i, j) * self.get_error_prob(j, self.n) total_packet_erasure += packet_erasure_at_i residual_packet_erasure_rate = (1 / self.k) * total_packet_erasure # Pr(k, n) if (residual_packet_erasure_rate <= prrtApplicationParameters.maxResidualLossRate): return True cdef class PrrtSocket: Loading @@ -221,6 +270,31 @@ cdef class PrrtSocket: cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket), cprrt.PrrtSocket_get_btlbw_back(self._c_socket)) property prrtSystemParameters: def __get__(self): TODO = "" # Measured by X-Lap return PrrtSystemParameters(cprrt.PrrtSocket_get_block_coding_delay, cprrt.PrrtSocket_get_redundancy_packet_transmission_delay, cprrt.PrrtSocket_get_processing_delay, # processing_delay cprrt.PrrtSocket_get_loss_detection_delay) # packet_loss_detection_delay property block_coding_delay: def __get__(self): return 0 property redundancy_packet_transmission_delay: def __get__(self, data): return len(data) / cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket) property processing_delay: def __get__(self): return 0 property packet_loss_detection_delay: def __get__(self) return 0 # property data_rate_btl_fwd: # def __get__(self): # return cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket) Loading Loading
prrt/prrt.pyx +78 −4 Original line number Diff line number Diff line Loading @@ -146,8 +146,33 @@ class ApplicationParameters: self.maxResidualLossRate) def __str__(self): return "({},{},{})".format(self.maxLatency, self.maxLatency) return "({},{})".format(self.maxLatency, self.maxResidualLossRate) class PrrtSystemParameters: def __init__(self, block_coding_delay, redundancy_packet_transmission_delay, processing_delay, packet_loss_detection_delay): self.block_coding_delay = block_coding_delay self.redundancy_packet_transmission_delay = redundancy_packet_transmission_delay self.processing_delay = processing_delay self.packet_loss_detection_delay = packet_loss_detection_delay def __repr__(self): return "PrrtSystemParameters(block_coding_delay={}," \ "redundancy_packet_transmission_delay={}," \ "processing_delay={}," \ "packet_loss_detection_delay={})".format(self.block_coding_delay, self.redundancy_packet_transmission_delay, self.processing_delay, self.packet_loss_detection_delay) def __str__(self): return "({},{},{},{})".format(self.block_coding_delay, self.redundancy_packet_transmission_delay, self.processing_delay, self.packet_loss_detection_delay) class PrrtCodingConfiguration: p_e = 0.0 Loading Loading @@ -175,7 +200,6 @@ class PrrtCodingConfiguration: # TODO # def __eq__() # TODO # Calculate the redundancy information this coding configuration causes, given a certain channel. def sum_error_prob_over_sent_packets(self, sent_packets_item): error_prob = 0 Loading @@ -196,7 +220,32 @@ class PrrtCodingConfiguration: # TODO # Check if it is able to fulfill application parameters given channel parameters. # def is_valid_for(applicationParameters, channelParameters) def hypergeometric_distribution(self, n, k, i, j): return (comb(k, i) * comb(n - k, j - i)) / comb(n, j) def is_valid_for(self, prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters): if (self.is_maximum_latency_fulfilled(prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters) and self.is_maximum_loss_fulfilled(prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters)): return True def is_maximum_latency_fulfilled(self, prrtApplicationParameters, prrtChannelParameters, prrtSystemParameters): fec_delay = prrtSystemParameters.block_coding_delay + self.n_p[0] * prrtSystemParameters.redundancy_packet_transmission_delay + \ (prrtChannelParameters.rtt_prop_fwd + prrtSystemParameters.processing_delay) / 2 + \ prrtSystemParameters.packet_loss_detection_delay req_delay_list = list(map(lambda c : prrtChannelParameters.rtt_prop_fwd + np.dot(self.n_p[c], prrtSystemParameters.redundancy_packet_transmission_delay) + prrtSystemParameters.processing_delay)) if (fec_delay + np.dot(self.len(self.n_p), req_delay_list) <= prrtApplicationParameters.maxLatency): return True def is_maximum_loss_fulfilled(self, prrtApplicationParameters): total_packet_erasure = 0 for i in range(1, self.k): for j in range(max(self.n - self.k + 1, i), self.n - self.k + i): packet_erasure_at_i = i * self.hypergeometric_distribution(self.n, self.k, i, j) * self.get_error_prob(j, self.n) total_packet_erasure += packet_erasure_at_i residual_packet_erasure_rate = (1 / self.k) * total_packet_erasure # Pr(k, n) if (residual_packet_erasure_rate <= prrtApplicationParameters.maxResidualLossRate): return True cdef class PrrtSocket: Loading @@ -221,6 +270,31 @@ cdef class PrrtSocket: cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket), cprrt.PrrtSocket_get_btlbw_back(self._c_socket)) property prrtSystemParameters: def __get__(self): TODO = "" # Measured by X-Lap return PrrtSystemParameters(cprrt.PrrtSocket_get_block_coding_delay, cprrt.PrrtSocket_get_redundancy_packet_transmission_delay, cprrt.PrrtSocket_get_processing_delay, # processing_delay cprrt.PrrtSocket_get_loss_detection_delay) # packet_loss_detection_delay property block_coding_delay: def __get__(self): return 0 property redundancy_packet_transmission_delay: def __get__(self, data): return len(data) / cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket) property processing_delay: def __get__(self): return 0 property packet_loss_detection_delay: def __get__(self) return 0 # property data_rate_btl_fwd: # def __get__(self): # return cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket) Loading