Commit 14415b99 authored by Ashkan Taslimi's avatar Ashkan Taslimi

Add skeleton of Application and Channel parameter classes.

Add TODO in PrrtCodingParameters
parent 49eb751a
......@@ -106,6 +106,47 @@ cdef sockaddr_to_addr_and_port(sockaddr_in addr):
class PayloadTooBigException(Exception):
pass
class PrrtChannelParameters:
def __init__(self,
loss_rate_fwd,
loss_rate_bwd,
rtt_prop_fwd,
rtt_prop_bwd,
data_rate_btl_fwd,
data_rate_btl_bwd):
self.loss_rate_fwd = loss_rate_fwd
self.loss_rate_bwd = loss_rate_bwd
self.rtt_prop_fwd = rtt_prop_fwd
self.rtt_prop_bwd = rtt_prop_bwd
self.data_rate_btl_fwd = data_rate_btl_fwd
self.data_rate_btl_bwd = data_rate_btl_bwd
def get_bandwidth_delay_fwd(self):
return self.data_rate_btl_fwd * self.rtt_prop_fwd
def get_bandwidth_delay_bwd(self):
return self.data_rate_btl_bwd * self.rtt_prop_bwd
# TODO
def get_ri_opt(self, applicationParameters):
return 0
class ApplicationParameters:
# maxLatency float in seconds
# maxResidualLossRate in percent
def __init__(self, maxLatency, maxResidualLossRate):
self.maxLatency = maxLatency
self.maxResidualLossRate = maxResidualLossRate
def __repr__(self):
return "ApplicationParameters(maxLatency={},maxResidualLossRate={})".format(self.maxLatency,
self.maxResidualLossRate)
def __str__(self):
return "({},{},{})".format(self.maxLatency, self.maxLatency)
class PrrtCodingConfiguration:
def __init__(self, n, k, n_cycle=None):
if n < k:
......@@ -128,6 +169,18 @@ class PrrtCodingConfiguration:
def __str__(self):
return "({},{},{})".format(self.n, self.k, self.n_cycle)
# TODO
# def __eq__()
# TODO
# Calculate the redundancy information this coding configuration causes, given a certain channel.
# ri = PrrtChannelParameters.get_ri_opt(applicationParameters)
# TODO
# Check if it is able to fulfill application parameters given channel parameters.
# def is_valid_for(applicationParameters, channelParameters)
cdef class PrrtSocket:
cdef cprrt.PrrtSocket* _c_socket
_epoch = datetime.datetime.utcfromtimestamp(0)
......@@ -141,21 +194,30 @@ cdef class PrrtSocket:
cprrt.PrrtSocket_bind(self._c_socket, host.encode("utf8"), port)
# Channel Properties
property data_rate_btl_fwd:
def __get__(self):
return cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket)
property data_rate_btl_back:
def __get__(self):
return cprrt.PrrtSocket_get_btlbw_back(self._c_socket)
property rtt_prop_fwd:
def __get__(self):
return cprrt.PrrtSocket_get_rtprop_fwd(self._c_socket) * 0.000001
property loss_rate_fwd:
property prrtChannelParameters:
def __get__(self):
return cprrt.PrrtSocket_get_plr_fwd(self._c_socket)
return PrrtChannelParameters(cprrt.PrrtSocket_get_plr_fwd(self._c_socket),
0, # TODO: Implement PrrtSocket_get_plr_bwd
cprrt.PrrtSocket_get_rtprop_fwd(self._c_socket) * 0.000001,
0, # TODO: Implement PrrtSocket_get_rtprop_bwd
cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket),
cprrt.PrrtSocket_get_btlbw_back(self._c_socket))
# property data_rate_btl_fwd:
# def __get__(self):
# return cprrt.PrrtSocket_get_btlbw_fwd(self._c_socket)
#
# property data_rate_btl_back:
# def __get__(self):
# return cprrt.PrrtSocket_get_btlbw_back(self._c_socket)
#
# property rtt_prop_fwd:
# def __get__(self):
# return cprrt.PrrtSocket_get_rtprop_fwd(self._c_socket) * 0.000001
#
# property loss_rate_fwd:
# def __get__(self):
# return cprrt.PrrtSocket_get_plr_fwd(self._c_socket)
# Application Properties
property target_delay:
......
Markdown is supported
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