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
d6bbe761
Commit
d6bbe761
authored
Mar 09, 2018
by
rna
Browse files
Coding parameters can be changed.
parent
07e048f0
Changes
7
Show whitespace changes
Inline
Side-by-side
prrt/cprrt.pxd
View file @
d6bbe761
...
...
@@ -36,7 +36,7 @@ cdef extern from "proto/codingParams.h":
ctypedef
prrtCodingParams
PrrtCodingParams
PrrtCodingParams
*
PrrtCodingParams_create
()
PrrtCodingParams
*
PrrtCodingParams_copy
(
PrrtCodingParams
*
cpar
)
bint
PrrtCodingParams_update
(
PrrtCodingParams
*
cpar
,
uint8_t
k
,
uint8_t
n
)
bint
PrrtCodingParams_update
(
PrrtCodingParams
*
cpar
,
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
)
bint
PrrtCodingParams_destroy
(
PrrtCodingParams
*
cpar
)
cdef
extern
from
"util/list.h"
:
...
...
@@ -137,7 +137,7 @@ cdef extern from "proto/socket.h":
bint
PrrtSocket_set_sock_opt
(
PrrtSocket
*
sock_ptr
,
const_char
*
name
,
const
uint32_t
value
)
uint32_t
PrrtSocket_get_sock_opt
(
PrrtSocket
*
sock_ptr
,
const_char
*
name
)
bint
PrrtSocket_set_coding_parameters
(
PrrtSocket
*
s
,
uint8_t
k
,
uint8_t
n
)
bint
PrrtSocket_set_coding_parameters
(
PrrtSocket
*
s
,
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
)
PrrtCodingParams
*
PrrtSocket_get_coding_parameters
(
PrrtSocket
*
s
)
bint
PrrtSocket_uses_thread_pinning
(
PrrtSocket
*
socket
)
uint32_t
PrrtSocket_get_rtprop
(
PrrtSocket
*
socket
)
...
...
prrt/proto/codingParams.c
View file @
d6bbe761
...
...
@@ -11,7 +11,9 @@ PrrtCodingParams *PrrtCodingParams_create(void)
pthread_mutex_init
(
&
cpar
->
lock
,
NULL
);
cpar
->
coder
=
NULL
;
PrrtCodingParams_update
(
cpar
,
K_START
,
N_START
);
uint8_t
*
n_cycle
=
calloc
(
1
,
sizeof
(
uint8_t
));
n_cycle
[
0
]
=
N_START
-
K_START
;
PrrtCodingParams_update
(
cpar
,
K_START
,
N_START
,
1
,
n_cycle
);
return
cpar
;
...
...
@@ -20,16 +22,15 @@ PrrtCodingParams *PrrtCodingParams_create(void)
return
NULL
;
}
bool
PrrtCodingParams_update
(
PrrtCodingParams
*
cpar
,
uint8_t
k
,
uint8_t
n
)
{
bool
PrrtCodingParams_update
(
PrrtCodingParams
*
cpar
,
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
)
{
cpar
->
k
=
k
;
cpar
->
n
=
n
;
cpar
->
r
=
cpar
->
n
-
cpar
->
k
;
cpar
->
c
=
1
;
cpar
->
c
=
c
;
if
(
cpar
->
n_cycle
!=
NULL
)
{
free
(
cpar
->
n_cycle
);
}
cpar
->
n_cycle
=
(
uint8_t
*
)
calloc
(
sizeof
(
uint8_t
),
cpar
->
c
);
cpar
->
n_cycle
[
0
]
=
(
cpar
->
n
-
cpar
->
k
);
cpar
->
n_cycle
=
n_cycle
;
PrrtCoder_get_coder
(
&
cpar
->
coder
,
n
,
k
);
return
true
;
}
...
...
prrt/proto/codingParams.h
View file @
d6bbe761
...
...
@@ -20,7 +20,7 @@ typedef struct prrtCodingParams {
PrrtCodingParams
*
PrrtCodingParams_create
(
void
);
PrrtCodingParams
*
PrrtCodingParams_copy
(
PrrtCodingParams
*
cpar
);
bool
PrrtCodingParams_update
(
PrrtCodingParams
*
cpar
,
uint8_t
k
,
uint8_t
n
);
bool
PrrtCodingParams_update
(
PrrtCodingParams
*
cpar
,
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
);
bool
PrrtCodingParams_destroy
(
PrrtCodingParams
*
cpar
);
#endif //PRRT_CODING_PARAMS_H
prrt/proto/processes/dataReceiver.c
View file @
d6bbe761
...
...
@@ -184,7 +184,7 @@ static void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) {
PrrtBlock
*
block
=
PrrtRepairBlockStore_get_block
(
socket
->
repairBlockStore
,
redundancyPayload
->
baseSequenceNumber
);
if
(
block
==
NULL
)
{
PrrtCodingParams_update
(
socket
->
codingParameters
,
redundancyPayload
->
k
,
redundancyPayload
->
n
);
PrrtCodingParams_update
(
socket
->
codingParameters
,
redundancyPayload
->
k
,
redundancyPayload
->
n
,
0
,
NULL
);
block
=
PrrtBlock_create
(
socket
->
codingParameters
,
redundancyPayload
->
baseSequenceNumber
);
...
...
prrt/proto/socket.c
View file @
d6bbe761
...
...
@@ -513,8 +513,8 @@ bool PrrtSocket_set_sock_opt(PrrtSocket *s, const char *name, const uint32_t val
return
true
;
}
bool
PrrtSocket_set_coding_parameters
(
PrrtSocket
*
s
,
uint8_t
k
,
uint8_t
n
)
{
PrrtCodingParams_update
(
s
->
codingParameters
,
k
,
n
);
bool
PrrtSocket_set_coding_parameters
(
PrrtSocket
*
s
,
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
)
{
PrrtCodingParams_update
(
s
->
codingParameters
,
k
,
n
,
c
,
n_cycle
);
return
true
;
}
...
...
prrt/proto/socket.h
View file @
d6bbe761
...
...
@@ -98,7 +98,7 @@ bool PrrtSocket_set_sock_opt(PrrtSocket *s, const char *name, const uint32_t val
uint32_t
PrrtSocket_get_sock_opt
(
PrrtSocket
*
s
,
const
char
*
name
);
bool
PrrtSocket_set_coding_parameters
(
PrrtSocket
*
s
,
uint8_t
k
,
uint8_t
n
);
bool
PrrtSocket_set_coding_parameters
(
PrrtSocket
*
s
,
uint8_t
k
,
uint8_t
n
,
uint8_t
c
,
uint8_t
*
n_cycle
);
PrrtCodingParams
*
PrrtSocket_get_coding_parameters
(
PrrtSocket
*
s
);
...
...
prrt/prrt.pyx
View file @
d6bbe761
from
libc.stdint
cimport
uint32_t
,
uint16_t
,
uint8_t
,
int32_t
from
libc.stdlib
cimport
malloc
,
free
from
posix.time
cimport
timespec
cimport
cython
cimport
cprrt
...
...
@@ -88,38 +89,21 @@ cdef extern from "util/pipe.c":
cdef
extern
from
"util/mpsc_queue.c"
:
pass
cdef
class
PrrtCodingConfiguration
:
cdef
cprrt
.
PrrtCodingParams
*
_c_config
def
__cinit__
(
self
):
self
.
_c_config
=
cprrt
.
PrrtCodingParams_create
()
def
__dealloc__
(
self
):
if
self
.
_c_config
!=
NULL
:
cprrt
.
PrrtCodingParams_destroy
(
self
.
_c_config
)
class
PrrtCodingConfiguration
:
def
__init__
(
self
,
n
,
k
,
n_cycle
):
# TODO: Validity checks
# n >= k
# sum(n_cycle) == n - k
self
.
n
=
n
self
.
k
=
k
self
.
n_cycle
=
n_cycle
def
__repr__
(
self
):
return
"PrrtCodingConfiguration(n={},k={},n_cycle=
[
{}
]
)"
.
format
(
self
.
n
,
self
.
k
,
","
.
join
(
map
(
str
,
self
.
n_cycle
)
))
return
"PrrtCodingConfiguration(n={},k={},n_cycle={})"
.
format
(
self
.
n
,
self
.
k
,
self
.
n_cycle
)
cdef
copy
(
self
,
cprrt
.
PrrtCodingParams
*
other
):
cprrt
.
PrrtCodingParams_destroy
(
self
.
_c_config
)
self
.
_c_config
=
other
property
k
:
def
__get__
(
self
):
return
int
(
self
.
_c_config
.
k
)
property
n
:
def
__get__
(
self
):
return
int
(
self
.
_c_config
.
n
)
property
r
:
def
__get__
(
self
):
return
int
(
self
.
_c_config
.
r
)
property
c
:
def
__get__
(
self
):
return
int
(
self
.
_c_config
.
c
)
property
n_cycle
:
def
__get__
(
self
):
return
list
(
<
uint8_t
[:
self
.
_c_config
.
c
]
>
self
.
_c_config
.
n_cycle
)
#property n_cycle:
# def __get__(self):
# return list(<uint8_t[:self._c_config.c]> self._c_config.n_cycle)
cdef
class
PrrtSocket
:
cdef
cprrt
.
PrrtSocket
*
_c_socket
...
...
@@ -175,10 +159,16 @@ cdef class PrrtSocket:
def
__get__
(
self
):
if
not
self
.
isSender
:
raise
Exception
(
"Not a sender."
)
res
=
PrrtCodingConfiguration
()
cdef
cprrt
.
PrrtCodingParams
*
params
=
cprrt
.
PrrtSocket_get_coding_parameters
(
self
.
_c_socket
)
res
.
copy
(
params
)
return
res
return
PrrtCodingConfiguration
(
params
.
n
,
params
.
k
,
list
(
<
uint8_t
[:
params
.
c
]
>
params
.
n_cycle
))
def
__set__
(
self
,
params
:
PrrtCodingConfiguration
):
cdef
uint8_t
*
n_cycle
c
=
len
(
params
.
n_cycle
)
n_cycle
=
<
uint8_t
*>
malloc
(
c
*
cython
.
sizeof
(
int
))
for
i
,
x
in
enumerate
(
params
.
n_cycle
):
n_cycle
[
i
]
=
x
cprrt
.
PrrtSocket_set_coding_parameters
(
self
.
_c_socket
,
params
.
k
,
params
.
n
,
c
,
n_cycle
)
property
delivery_rate
:
def
__get__
(
self
):
...
...
Andreas Schmidt
@as
mentioned in issue
#10 (closed)
·
Mar 09, 2018
mentioned in issue
#10 (closed)
mentioned in issue #10
Toggle commit list
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