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
c20b5a8a
Commit
c20b5a8a
authored
Mar 15, 2016
by
Andreas Schmidt
Browse files
Channel state information is now a normal object. Add application constraints.
parent
220d1945
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/prrt/CMakeLists.txt
View file @
c20b5a8a
add_library
(
PRRT ../defines.h socket.c block.c block.h packet.c packet.h receiver.c receiver.h clock.c clock.h channelStateInformation.c channelStateInformation.h processes/feedbackReceiver.c processes/feedbackReceiver.h processes/dataTransmitter.c processes/dataTransmitter.h codingParams.c codingParams.h vdmcode/block_code.c vdmcode/block_code.h codingParams.c codingParams.h stores/forwardPacketTable.c stores/forwardPacketTable.h processes/dataReceiver.c processes/dataReceiver.h
)
add_library
(
PRRT ../defines.h socket.c block.c block.h packet.c packet.h receiver.c receiver.h clock.c clock.h channelStateInformation.c channelStateInformation.h processes/feedbackReceiver.c processes/feedbackReceiver.h processes/dataTransmitter.c processes/dataTransmitter.h codingParams.c codingParams.h
applicationContraints.c applicationContraints.h
vdmcode/block_code.c vdmcode/block_code.h codingParams.c codingParams.h stores/forwardPacketTable.c stores/forwardPacketTable.h processes/dataReceiver.c processes/dataReceiver.h
)
set_property
(
TARGET PRRT PROPERTY C_STANDARD 99
)
\ No newline at end of file
src/prrt/applicationContraints.c
0 → 100644
View file @
c20b5a8a
#include
<malloc.h>
#include
"../util/common.h"
#include
"../util/dbg.h"
#include
"applicationContraints.h"
PrrtApplicationConstraints
*
PrrtNetworkConstraints_create
()
{
PrrtApplicationConstraints
*
constraints
=
calloc
(
1
,
sizeof
(
PrrtApplicationConstraints
));
check_mem
(
constraints
);
return
constraints
;
error:
PERROR
(
"Not enough memory%s."
,
""
);
return
NULL
;
}
bool
PrrtNetworkConstraints_destroy
(
PrrtApplicationConstraints
*
applicationConstraints
)
{
free
(
applicationConstraints
);
return
true
;
}
prrtTimedelta_t
PrrtNetworkConstraints_get_target_delay
(
PrrtApplicationConstraints
*
applicationConstraints
)
{
return
applicationConstraints
->
targetDelay
;
}
src/prrt/applicationContraints.h
0 → 100644
View file @
c20b5a8a
#ifndef PRRT_NETWORKCONTRAINTS_H
#define PRRT_NETWORKCONTRAINTS_H
#include
"packet.h"
typedef
struct
applicationConstraints
{
prrtTimedelta_t
targetDelay
;
}
PrrtApplicationConstraints
;
PrrtApplicationConstraints
*
PrrtNetworkConstraints_create
(
void
);
bool
PrrtNetworkConstraints_destroy
(
PrrtApplicationConstraints
*
applicationConstraints
);
prrtTimedelta_t
PrrtNetworkConstraints_get_target_delay
(
PrrtApplicationConstraints
*
applicationConstraints
);
#endif //PRRT_NETWORKCONTRAINTS_H
src/prrt/channelStateInformation.c
View file @
c20b5a8a
...
...
@@ -4,22 +4,26 @@
#include
"../util/dbg.h"
#include
"channelStateInformation.h"
void
PrrtChannelStateInformation_init
(
PrrtChannelStateInformation
*
csi
)
// TODO: LOCKS
PrrtChannelStateInformation
*
PrrtChannelStateInformation_create
()
{
check
(
csi
!=
NULL
,
"Input should not be NULL."
);
PrrtChannelStateInformation
*
csi
=
calloc
(
1
,
sizeof
(
PrrtChannelStateInformation
));
check_mem
(
csi
);
csi
->
rttMean
=
0
;
csi
->
rttDev
=
0
;
return
;
return
csi
;
error:
PERROR
(
"Should not happen.%s"
,
""
);
return
NULL
;
}
void
PrrtChannelStateInformation_update_rtt
(
PrrtChannelStateInformation
*
csi
,
prrtTimedelta_t
rtt
)
{
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
=
(
prrtTimedelta_t
)
(
csi
->
rttMean
+
RRT_ALPHA
*
delta
);
csi
->
rttDev
=
(
prrtTimedelta_t
)
(
csi
->
rttDev
+
RRT_ALPHA
*
(
labs
(
delta
)
-
csi
->
rttDev
));
}
...
...
@@ -32,4 +36,15 @@ void PrrtChannelStateInformation_print(PrrtChannelStateInformation *csi)
return
;
error:
PERROR
(
"Should not happen.%s"
,
""
);
}
\ No newline at end of file
}
prrtTimedelta_t
PrrtChannelStateInformation_get_rtt
(
PrrtChannelStateInformation
*
csi
)
{
return
csi
->
rttMean
;
}
bool
PrrtChannelStateInformation_destroy
(
PrrtChannelStateInformation
*
csi
)
{
free
(
csi
);
return
true
;
}
src/prrt/channelStateInformation.h
View file @
c20b5a8a
...
...
@@ -8,8 +8,10 @@ typedef struct prrtChannelStateInformation {
prrtTimedelta_t
rttDev
;
}
PrrtChannelStateInformation
;
void
PrrtChannelStateInformation
_init
(
PrrtChannelStateInformation
*
csi
);
PrrtChannelStateInformation
*
PrrtChannelStateInformation
_create
(
void
);
void
PrrtChannelStateInformation_update_rtt
(
PrrtChannelStateInformation
*
csi
,
prrtTimedelta_t
rtt
);
prrtTimedelta_t
PrrtChannelStateInformation_get_rtt
(
PrrtChannelStateInformation
*
csi
);
bool
PrrtChannelStateInformation_destroy
(
PrrtChannelStateInformation
*
csi
);
void
PrrtChannelStateInformation_print
(
PrrtChannelStateInformation
*
csi
);
...
...
src/prrt/processes/dataTransmitter.c
View file @
c20b5a8a
...
...
@@ -81,8 +81,8 @@ void * send_data_loop(void *ptr) {
packet
->
index
=
(
uint8_t
)
(
packet
->
sequenceNumber
-
block
->
baseSequenceNumber
);
PrrtPacketDataPayload
*
payload
=
packet
->
payload
;
// TODO: should lock here !
payload
->
groupRTT_us
=
sock_ptr
->
csi
.
rttMean
;
payload
->
groupRTT_us
=
PrrtChannelStateInformation_get_rtt
(
sock_ptr
->
csi
);
payload
->
packetTimeout_us
=
PrrtNetworkConstraints_get_target_delay
(
sock_ptr
->
applicationConstraints
)
;
PrrtPacket
*
packetToSend
=
PrrtPacket_copy
(
packet
);
send_packet
(
sock_ptr
,
packetToSend
);
...
...
src/prrt/socket.c
View file @
c20b5a8a
...
...
@@ -28,7 +28,8 @@ PrrtSocket *PrrtSocket_create(const bool is_sender)
sock_ptr
->
sequenceNumberSource
=
1
;
sock_ptr
->
sequenceNumberRedundancy
=
1
;
PrrtChannelStateInformation_init
(
&
sock_ptr
->
csi
);
sock_ptr
->
csi
=
PrrtChannelStateInformation_create
();
sock_ptr
->
applicationConstraints
=
PrrtNetworkConstraints_create
();
sock_ptr
->
dataStore
=
NULL
;
...
...
@@ -259,6 +260,9 @@ int PrrtSocket_close(PrrtSocket *sock_ptr) {
free
(
sock_ptr
->
address
);
}
check
(
PrrtChannelStateInformation_destroy
(
sock_ptr
->
csi
),
"Could not destroy channel state information."
)
check
(
PrrtNetworkConstraints_destroy
(
sock_ptr
->
applicationConstraints
),
"Could not destroy application constraints."
)
close
(
sock_ptr
->
dataSocketFd
);
close
(
sock_ptr
->
feedbackSocketFd
);
debug
(
"Socket closed."
);
...
...
@@ -301,7 +305,7 @@ PrrtPacket *PrrtSocket_recv_feedback(PrrtSocket *prrtSocket, const size_t length
printf
(
"%s
\n
"
,
inet_ntoa
(
a
));
prrtTimestamp_t
forwardTripTimestamp
=
((
PrrtPacketFeedbackPayload
*
)
prrtPacket
->
payload
)
->
forwardTripTimestamp_us
;
PrrtChannelStateInformation_update_rtt
(
&
prrtSocket
->
csi
,
receiveTime
-
forwardTripTimestamp
);
PrrtChannelStateInformation_update_rtt
(
prrtSocket
->
csi
,
receiveTime
-
forwardTripTimestamp
);
return
prrtPacket
;
...
...
src/prrt/socket.h
View file @
c20b5a8a
...
...
@@ -7,6 +7,7 @@
#include
"../util/list.h"
#include
"../util/bptree.h"
#include
"channelStateInformation.h"
#include
"applicationContraints.h"
typedef
struct
prrtSocket
{
...
...
@@ -48,7 +49,9 @@ typedef struct prrtSocket {
prrtTimestamp_t
lastSentTimestamp
;
prrtTimestamp_t
lastReceivedTimestamp
;
PrrtChannelStateInformation
csi
;
PrrtChannelStateInformation
*
csi
;
PrrtApplicationConstraints
*
applicationConstraints
;
}
PrrtSocket
;
...
...
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