Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
PRRT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
37
Issues
37
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LARN
PRRT
Commits
770f62df
Commit
770f62df
authored
Jun 09, 2017
by
Andreas Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract xlap timestamping into separate module.
parent
9ad12fa7
Pipeline
#976
passed with stages
in 1 minute and 8 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
86 additions
and
278 deletions
+86
-278
.gitlab-ci.yml
.gitlab-ci.yml
+1
-0
.gitmodules
.gitmodules
+3
-0
prrt/cprrt.pxd
prrt/cprrt.pxd
+4
-4
prrt/proto/CMakeLists.txt
prrt/proto/CMakeLists.txt
+1
-1
prrt/proto/processes/dataReceiver.c
prrt/proto/processes/dataReceiver.c
+23
-23
prrt/proto/processes/dataTransmitter.c
prrt/proto/processes/dataTransmitter.c
+10
-10
prrt/proto/socket.c
prrt/proto/socket.c
+20
-20
prrt/proto/socket.h
prrt/proto/socket.h
+2
-2
prrt/proto/timestamp.c
prrt/proto/timestamp.c
+0
-32
prrt/proto/timestamp.h
prrt/proto/timestamp.h
+0
-165
prrt/prrt.pyx
prrt/prrt.pyx
+7
-7
prrt/receiver.c
prrt/receiver.c
+7
-7
prrt/sender.c
prrt/sender.c
+7
-7
prrt/xlap
prrt/xlap
+1
-0
No files found.
.gitlab-ci.yml
View file @
770f62df
variables
:
PYPI_USER
:
SECURE
PYPI_PASSWORD
:
SECURE
GIT_SUBMODULE_STRATEGY
:
recursive
stages
:
-
build
...
...
.gitmodules
0 → 100644
View file @
770f62df
[submodule "prrt/xlap"]
path = prrt/xlap
url = ../../as/X-Lap.git
prrt/cprrt.pxd
View file @
770f62df
...
...
@@ -121,16 +121,16 @@ 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
)
cdef
extern
from
"
proto/timestam
p.h"
:
ctypedef
struct
Prrt
TimestampTable
:
cdef
extern
from
"
xlap/xla
p.h"
:
ctypedef
struct
Xlap
TimestampTable
:
pass
cdef
enum
Prrt
TimestampPacketKind
:
cdef
enum
Xlap
TimestampPacketKind
:
ts_data_packet
=
0
,
ts_any_packet
=
0
,
ts_redundancy_packet
=
1
void
PrrtTimestampTableInstall
(
PrrtSocket
*
sck
,
PrrtTimestampPacketKind
kind
,
Prrt
TimestampTable
*
tstp
);
void
XlapTimestampTableInstall
(
PrrtSocket
*
sck
,
XlapTimestampPacketKind
kind
,
Xlap
TimestampTable
*
tstp
);
cdef
extern
from
"util/bptree.h"
:
ctypedef
struct
BPTreeNode
:
...
...
prrt/proto/CMakeLists.txt
View file @
770f62df
...
...
@@ -6,7 +6,7 @@ add_library(PRRT ../defines.h
packet.c packet.h
receiver.c receiver.h
socket.c socket.h
timestamp.c timestam
p.h
../xlap/xlap.c ../xlap/xla
p.h
applicationConstraints.c applicationConstraints.h
vdmcode/block_code.c vdmcode/block_code.h
stores/forwardPacketTable.c stores/forwardPacketTable.h
...
...
prrt/proto/processes/dataReceiver.c
View file @
770f62df
...
...
@@ -111,9 +111,9 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct
prrtSequenceNumber_t
seqno
=
packet
->
sequenceNumber
;
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
SendFeedbackStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
SendFeedbackStart
);
check
(
send_feedback
(
sock_ptr
,
remote
),
"Sending feedback failed."
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
SendFeedbackEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
SendFeedbackEnd
);
prrtTimestamp_t
now
=
PrrtClock_get_prrt_time_us
(
&
sock_ptr
->
clock
);
if
(
is_timeout
(
now
,
payload
->
packetTimeout_us
))
{
...
...
@@ -144,7 +144,7 @@ static void handle_data_packet(PrrtSocket *sock_ptr, PrrtPacket *packet, struct
// forward to application layer
debug
(
DEBUG_DATARECEIVER
,
"forward %u"
,
seqno
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
PrrtReturnPackage
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
PrrtReturnPackage
);
check
(
pthread_mutex_lock
(
&
sock_ptr
->
inQueueFilledMutex
)
==
0
,
"Lock failed."
);
List_push
(
sock_ptr
->
inQueue
,
packet
);
check
(
pthread_cond_signal
(
&
sock_ptr
->
inQueueFilledCv
)
==
0
,
"Cond signal failed."
);
...
...
@@ -198,46 +198,46 @@ void *receive_data_loop(void *ptr)
PrrtSocket
*
sock_ptr
=
ptr
;
while
(
1
)
{
Prrt
TimestampPlaceholder
tsph1
;
Prrt
TimestampPlaceholder
tsph2
;
Prrt
TimestampPlaceholder
tsph3
;
Prrt
TimestampPlaceholderInitialize
(
&
tsph1
);
Prrt
TimestampPlaceholderInitialize
(
&
tsph2
);
Prrt
TimestampPlaceholderInitialize
(
&
tsph3
);
Xlap
TimestampPlaceholder
tsph1
;
Xlap
TimestampPlaceholder
tsph2
;
Xlap
TimestampPlaceholder
tsph3
;
Xlap
TimestampPlaceholderInitialize
(
&
tsph1
);
Xlap
TimestampPlaceholderInitialize
(
&
tsph2
);
Xlap
TimestampPlaceholderInitialize
(
&
tsph3
);
memset
(
buffer
,
0
,
MAX_PAYLOAD_LENGTH
);
n
=
recvfrom
(
sock_ptr
->
dataSocketFd
,
buffer
,
MAX_PAYLOAD_LENGTH
,
0
,
(
struct
sockaddr
*
)
&
remote
,
&
addrlen
);
sock_ptr
->
lastReceivedTimestamp
=
PrrtClock_get_current_time_us
();
Prrt
TimeStampClock
(
&
tsph1
,
ts_any_packet
,
0
,
LinkReceive
);
Prrt
TimeStampCycle
(
&
tsph1
,
ts_any_packet
,
0
,
LinkReceive
);
Xlap
TimeStampClock
(
&
tsph1
,
ts_any_packet
,
0
,
LinkReceive
);
Xlap
TimeStampCycle
(
&
tsph1
,
ts_any_packet
,
0
,
LinkReceive
);
PrrtPacket
*
packet
=
(
PrrtPacket
*
)
calloc
(
1
,
sizeof
(
PrrtPacket
));
check_mem
(
packet
);
Prrt
TimeStampCycle
(
&
tsph2
,
ts_any_packet
,
0
,
DecodeStart
);
Xlap
TimeStampCycle
(
&
tsph2
,
ts_any_packet
,
0
,
DecodeStart
);
check
(
PrrtPacket_decode
(
buffer
,
(
uint16_t
)
n
,
packet
),
"Decode failed."
);
Prrt
TimeStampCycle
(
&
tsph3
,
ts_any_packet
,
0
,
DecodeEnd
);
Xlap
TimeStampCycle
(
&
tsph3
,
ts_any_packet
,
0
,
DecodeEnd
);
prrtSequenceNumber_t
seqno
=
packet
->
sequenceNumber
;
prrtPacketType_t
packetType
=
PrrtPacket_type
(
packet
);
debug
(
DEBUG_DATARECEIVER
,
"received packet %d:%u"
,
(
int
)
packetType
,
seqno
);
if
(
packetType
==
PACKET_TYPE_DATA
)
{
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
seqno
,
&
tsph1
);
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
seqno
,
&
tsph2
);
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
seqno
,
&
tsph3
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
seqno
,
&
tsph1
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
seqno
,
&
tsph2
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
seqno
,
&
tsph3
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
HandlePacketStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
HandlePacketStart
);
handle_data_packet
(
sock_ptr
,
packet
,
remote
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
HandlePacketEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
seqno
,
HandlePacketEnd
);
}
else
if
(
packetType
==
PACKET_TYPE_REDUNDANCY
)
{
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
&
tsph1
);
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
&
tsph2
);
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
&
tsph3
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
&
tsph1
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
&
tsph2
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
&
tsph3
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
HandlePacketStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
HandlePacketStart
);
handle_redundancy_packet
(
sock_ptr
,
packet
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
HandlePacketEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
seqno
,
HandlePacketEnd
);
}
else
{
PrrtPacket_print
(
packet
);
PrrtPacket_destroy
(
packet
);
...
...
prrt/proto/processes/dataTransmitter.c
View file @
770f62df
...
...
@@ -21,10 +21,10 @@ static bool send_packet(PrrtSocket *sock_ptr, PrrtPacket *packet)
switch
(
PrrtPacket_type
(
packet
))
{
case
PACKET_TYPE_DATA
:
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
LinkTransmitStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
LinkTransmitStart
);
break
;
case
PACKET_TYPE_REDUNDANCY
:
Prrt
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
packet
->
sequenceNumber
,
LinkTransmitStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
packet
->
sequenceNumber
,
LinkTransmitStart
);
break
;
case
PACKET_TYPE_REPETITION
:
case
PACKET_TYPE_FEEDBACK
:
...
...
@@ -43,12 +43,12 @@ static bool send_packet(PrrtSocket *sock_ptr, PrrtPacket *packet)
}
switch
(
PrrtPacket_type
(
packet
))
{
case
PACKET_TYPE_DATA
:
Prrt
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
break
;
case
PACKET_TYPE_REDUNDANCY
:
Prrt
TimeStampClock
(
sock_ptr
,
ts_redundancy_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_redundancy_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
packet
->
sequenceNumber
,
LinkTransmitEnd
);
break
;
case
PACKET_TYPE_REPETITION
:
case
PACKET_TYPE_FEEDBACK
:
...
...
@@ -86,7 +86,7 @@ void *send_data_loop(void *ptr)
}
PrrtPacket
*
packet
=
List_shift
(
sock_ptr
->
outQueue
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtTransmitStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtTransmitStart
);
if
(
block
==
NULL
)
{
block
=
PrrtBlock_create
(
sock_ptr
->
codingParameters
,
packet
->
sequenceNumber
);
}
...
...
@@ -98,7 +98,7 @@ void *send_data_loop(void *ptr)
PrrtPacket
*
packetToSend
=
PrrtPacket_copy
(
packet
);
send_packet
(
sock_ptr
,
packetToSend
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtTransmitEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtTransmitEnd
);
PrrtBlock_insert_data_packet
(
block
,
packet
);
...
...
@@ -106,9 +106,9 @@ void *send_data_loop(void *ptr)
if
(
PrrtBlock_encode_ready
(
block
))
{
uint32_t
j
=
0
;
unsigned
int
redundancy_seqno
=
sock_ptr
->
sequenceNumberRedundancy
;
Prrt
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
redundancy_seqno
,
PrrtEncodeStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
redundancy_seqno
,
PrrtEncodeStart
);
PrrtBlock_encode
(
block
,
&
sock_ptr
->
sequenceNumberRedundancy
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
redundancy_seqno
,
PrrtEncodeEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_redundancy_packet
,
redundancy_seqno
,
PrrtEncodeEnd
);
uint32_t
redundancyPackets
=
List_count
(
block
->
redundancyPackets
);
for
(
j
=
0
;
j
<
redundancyPackets
;
j
++
)
{
...
...
prrt/proto/socket.c
View file @
770f62df
...
...
@@ -152,24 +152,24 @@ int PrrtSocket_connect(PrrtSocket *sock_ptr, const char *host, const uint16_t po
int
PrrtSocket_send
(
PrrtSocket
*
sock_ptr
,
const
uint8_t
*
data
,
const
size_t
data_len
)
{
check
(
sock_ptr
->
isSender
,
"Cannot send on receiver socket."
)
Prrt
TimestampPlaceholder
tsph
;
Prrt
TimestampPlaceholderInitialize
(
&
tsph
);
Prrt
TimeStampClock
(
&
tsph
,
ts_any_packet
,
0
,
PrrtSendStart
);
Prrt
TimeStampCycle
(
&
tsph
,
ts_any_packet
,
0
,
PrrtSendStart
);
Xlap
TimestampPlaceholder
tsph
;
Xlap
TimestampPlaceholderInitialize
(
&
tsph
);
Xlap
TimeStampClock
(
&
tsph
,
ts_any_packet
,
0
,
PrrtSendStart
);
Xlap
TimeStampCycle
(
&
tsph
,
ts_any_packet
,
0
,
PrrtSendStart
);
prrtSequenceNumber_t
sequenceNumber
=
sock_ptr
->
sequenceNumberSource
++
;
PrrtPacket
*
packet
=
PrrtPacket_create_data_packet
(
5
,
data
,
(
prrtPacketLength_t
)
data_len
,
sequenceNumber
,
PrrtApplicationConstraints_get_target_delay
(
sock_ptr
->
applicationConstraints
));
Prrt
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
&
tsph
);
Xlap
TimestampPlaceholderUse
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
&
tsph
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtSubmitPackage
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtSubmitPackage
);
check
(
pthread_mutex_lock
(
&
sock_ptr
->
outQueueFilledMutex
)
==
0
,
"Lock failed."
);
List_push
(
sock_ptr
->
outQueue
,
packet
);
check
(
pthread_cond_signal
(
&
sock_ptr
->
outQueueFilledCv
)
==
0
,
"Signal failed."
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
outQueueFilledMutex
)
==
0
,
"Unlock failed"
);
Prrt
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtSendEnd
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtSendEnd
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtSendEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtSendEnd
);
return
0
;
error:
PERROR
(
"There was a failure while sending from socket.%s"
,
""
);
...
...
@@ -190,19 +190,19 @@ int32_t PrrtSocket_recv(PrrtSocket *sock_ptr, void *buf_ptr)
check
(
pthread_cond_wait
(
&
sock_ptr
->
inQueueFilledCv
,
&
sock_ptr
->
inQueueFilledMutex
)
==
0
,
"Wait failed."
);
}
PrrtPacket
*
packet
=
List_shift
(
sock_ptr
->
inQueue
);
Prrt
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
prrtPacketLength_t
len
=
(
prrtPacketLength_t
)
(
packet
->
payloadLength
-
PRRT_PACKET_DATA_HEADER_SIZE
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputStart
);
PrrtPacket_copy_payload_to_buffer
(
buf_ptr
,
packet
,
PRRT_PACKET_DATA_HEADER_SIZE
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputEnd
);
debug
(
DEBUG_SOCKET
,
"len: %d"
,
(
int
)
len
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
inQueueFilledMutex
)
==
0
,
"Unlock failed."
);
Prrt
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
PrrtPacket_destroy
(
packet
);
return
len
;
}
...
...
@@ -237,19 +237,19 @@ int32_t PrrtSocket_timedrecv(PrrtSocket *sock_ptr, void *buf_ptr, const uint32_t
}
}
PrrtPacket
*
packet
=
List_shift
(
sock_ptr
->
inQueue
);
Prrt
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtReceivePackage
);
prrtPacketLength_t
len
=
(
prrtPacketLength_t
)
(
packet
->
payloadLength
-
PRRT_PACKET_DATA_HEADER_SIZE
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputStart
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputStart
);
PrrtPacket_copy_payload_to_buffer
(
buf_ptr
,
packet
,
PRRT_PACKET_DATA_HEADER_SIZE
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputEnd
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
CopyOutputEnd
);
debug
(
DEBUG_SOCKET
,
"len: %d"
,
(
int
)
len
);
check
(
pthread_mutex_unlock
(
&
sock_ptr
->
inQueueFilledMutex
)
==
0
,
"Unlock failed."
);
Prrt
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
Prrt
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
Xlap
TimeStampClock
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
Xlap
TimeStampCycle
(
sock_ptr
,
ts_data_packet
,
packet
->
sequenceNumber
,
PrrtDeliver
);
PrrtPacket_destroy
(
packet
);
return
len
;
}
...
...
prrt/proto/socket.h
View file @
770f62df
...
...
@@ -14,7 +14,7 @@
#include "stores/packetTimeoutTable.h"
#include "stores/repairBlockStore.h"
#include "clock.h"
#include "
timestam
p.h"
#include "
../xlap/xla
p.h"
typedef
struct
prrtSocket
{
...
...
@@ -63,7 +63,7 @@ typedef struct prrtSocket {
PrrtCodingParams
*
codingParameters
;
_Atomic
(
Prrt
TimestampTable
*
)
tstable
[
2
];
_Atomic
(
Xlap
TimestampTable
*
)
tstable
[
2
];
pthread_attr_t
*
receiveFeedbackThreadAttr
;
pthread_attr_t
*
sendDataThreadAttr
;
...
...
prrt/proto/timestamp.c
deleted
100644 → 0
View file @
9ad12fa7
#include "timestamp.h"
#include <stdatomic.h>
void
PrrtTimestampTableDumpHeader
(
FILE
*
out
)
{
fprintf
(
out
,
"SeqNo,Kind"
);
# define OUT(id) fprintf(out, ",%s_T,%s_C", #id, #id);
PP_foreach
(
PP_join_space
,
OUT
,
TIMESTAMP_ID_LIST
)
# undef OUT
fprintf
(
out
,
"
\n
"
);
}
static
inline
unsigned
long
long
timestampByTime
(
struct
timespec
*
ts
)
{
// convert timespec to microseconds
unsigned
long
long
x
=
ts
->
tv_sec
;
x
*=
1000000ULL
;
x
+=
ts
->
tv_nsec
/
1000
;
return
x
;
}
void
PrrtTimestampTableDump
(
FILE
*
out
,
PrrtTimestampPacketKind
kind
,
PrrtTimestampTable
*
table
)
{
# define OUT(id) fprintf(out, ",%llu,%llu", timestampByTime(&table->rows[row].time[ts_##id].actual.t), (unsigned long long) table->rows[row].time[ts_##id].actual.c);
for
(
unsigned
int
row
=
0
;
row
<
TS_ROWS
;
row
++
)
{
fprintf
(
out
,
"%u,%u"
,
row
,
(
unsigned
)
kind
);
PP_foreach
(
PP_join_space
,
OUT
,
TIMESTAMP_ID_LIST
)
fprintf
(
out
,
"
\n
"
);
}
# undef OUT
}
prrt/proto/timestamp.h
deleted
100644 → 0
View file @
9ad12fa7
#ifndef PRRT_TIMESTAMP_H
#define PRRT_TIMESTAMP_H
#include <stdio.h>
#include <stdint.h>
#include <time.h>
/*
* Each timestamp contains both a cycle value and a time value, but some values
* might remain zero
*/
typedef
union
PrrtTimestamp
{
struct
PrrtActualTimestamp
{
uint64_t
c
;
struct
timespec
t
;
}
actual
;
char
_cacheline
[
64
];
}
PrrtTimestamp
;
#include "../util/pp.h"
/*
* Comma-separated list of timestamp IDs
*/
#define TIMESTAMP_ID_LIST \
PrrtSendStart, \
PrrtSendEnd, \
PrrtSubmitPackage, \
PrrtEncodeStart, \
PrrtEncodeEnd, \
PrrtTransmitStart, \
PrrtTransmitEnd, \
LinkTransmitStart, \
LinkTransmitEnd, \
LinkReceive, \
DecodeStart, \
DecodeEnd, \
HandlePacketStart, \
HandlePacketEnd, \
CopyOutputStart, \
CopyOutputEnd, \
SendFeedbackStart, \
SendFeedbackEnd, \
PrrtReturnPackage, \
PrrtReceivePackage, \
PrrtDeliver \
#define TIMESSTAMP_ID_TO_NAME(id) ts_##id
/*
* enum containing all timestamp IDs
*/
typedef
enum
PrrtTimestampId
{
PP_foreach
(
PP_join_comma
,
TIMESSTAMP_ID_TO_NAME
,
TIMESTAMP_ID_LIST
),
ts_count
}
PrrtTimestampId
;
/*
* enum to distinguish between data and redundancy packet timstamps
*/
typedef
enum
PrrtTimestampPacketKind
{
ts_data_packet
=
0
,
ts_any_packet
=
0
,
ts_redundancy_packet
=
1
,
}
PrrtTimestampPacketKind
;
/*
* Table that stores timestamps for each timestamp ID
*/
typedef
struct
PrrtTimestampTableRow
{
PrrtTimestamp
time
[
ts_count
];
}
PrrtTimestampTableRow
;
/*
* by default, store timestamps for 128 packages
*/
#ifndef TS_ROWS
#define TS_ROWS (1u<<12)
#endif
/*
* Table that stores timestamp table rows
*/
typedef
struct
PrrtTimestampTable
{
PrrtTimestampTableRow
rows
[
TS_ROWS
];
}
PrrtTimestampTable
;
/*
* Dummy data structure to store a single timestamp table row.
*/
typedef
struct
PrrtTimestampPlaceholder
{
_Atomic
(
PrrtTimestampTable
*
)
tstable
[
1
];
PrrtTimestampTableRow
rows
[
1
];
}
PrrtTimestampPlaceholder
;
/*
* update the clock value of a timestamp
*
* This macro will cause a SIGSEGV if the application does not install a
* timestamp table to the prrt socket.
*/
#define PrrtTimeStampClock(sck, kind, seqno, id) do { \
clock_gettime(CLOCK_MONOTONIC, &atomic_load_explicit(&(sck)->tstable[kind], memory_order_acquire)->rows[(seqno) % TS_ROWS].time[ts_##id].actual.t); \
} while (0);
/*
* update the cycle value of a timestamp
*
* This macro will cause a SIGSEGV if the application does not install a
* timestamp table to the prrt socket.
*/
#define PrrtTimeStampCycle(sck, kind, seqno, id) do { \
atomic_load_explicit(&(sck)->tstable[kind], memory_order_acquire)->rows[(seqno) % TS_ROWS].time[ts_##id].actual.c = __builtin_ia32_rdtsc(); \
} while (0);
/*
* install a time stamp table to a socket
*/
#define PrrtTimestampTableInstall(sck, kind, tstp) do { \
PrrtTimestampTable *__tstp = (tstp); \
memset(__tstp, 0, sizeof(PrrtTimestampTable)); \
atomic_store_explicit(&(sck)->tstable[kind], __tstp, memory_order_release); \
} while (0)
/*
* print a timestamp dump header
*/
extern
void
PrrtTimestampTableDumpHeader
(
FILE
*
);
/*
* dump a timestamp table
*/
extern
void
PrrtTimestampTableDump
(
FILE
*
,
PrrtTimestampPacketKind
,
PrrtTimestampTable
*
);
/*
* use a specific timestamp table
*/
extern
void
PrrtTimestampTableUse
(
PrrtTimestampTable
*
);
/*
* intialize a timestamp table placeholder
*/
#define PrrtTimestampPlaceholderInitialize(ph) do { \
PrrtTimestampPlaceholder *__ph = (ph); \
atomic_store_explicit(&__ph->tstable[0], (PrrtTimestampTable *) &__ph->rows, memory_order_release); \
memset(&__ph->rows, 0x0, sizeof(PrrtTimestampTableRow)); \
} while (0);
/*
* copy a timestamp table placeholder into an actual timestamp table
*
* Since every timestamp is taken at most once, either the timestamptable or
* the placeholder value must be zero (for each timestamp).
*/
#define PrrtTimestampPlaceholderUse(sck, kind, seqno, ph) do { \
PrrtTimestampPlaceholder *__ph = (ph); \
PrrtTimestampTable *__ts = atomic_load_explicit(&(sck)->tstable[kind], memory_order_acquire); \
for (unsigned int __t = 0; __t < ts_count; __t++) { \
__ts->rows[seqno % TS_ROWS].time[__t].actual.t.tv_sec += __ph->rows[0].time[__t].actual.t.tv_sec; \
__ts->rows[seqno % TS_ROWS].time[__t].actual.t.tv_nsec += __ph->rows[0].time[__t].actual.t.tv_nsec; \
__ts->rows[seqno % TS_ROWS].time[__t].actual.c += __ph->rows[0].time[__t].actual.c; \
} \
} while (0)
#endif // PRRT_TIMESTAMP_H
prrt/prrt.pyx
View file @
770f62df
...
...
@@ -6,7 +6,7 @@ cimport cprrt
cdef
extern
from
"proto/applicationConstraints.c"
:
pass
cdef
extern
from
"
proto/timestam
p.c"
:
cdef
extern
from
"
xlap/xla
p.c"
:
pass
cdef
extern
from
"proto/stores/dataPacketStore.c"
:
...
...
@@ -69,18 +69,18 @@ cdef extern from "util/list.c":
cdef
class
PrrtSocket
:
cdef
cprrt
.
PrrtSocket
*
_c_socket
cdef
bint
isSender
cdef
cprrt
.
Prrt
TimestampTable
*
tstable_data
cdef
cprrt
.
Prrt
TimestampTable
*
tstable_redundancy
cdef
cprrt
.
Xlap
TimestampTable
*
tstable_data
cdef
cprrt
.
Xlap
TimestampTable
*
tstable_redundancy
def
__cinit__
(
self
,
port
,
isSender
):
self
.
_c_socket
=
cprrt
.
PrrtSocket_create
(
isSender
)
cprrt
.
PrrtSocket_bind
(
self
.
_c_socket
,
"0.0.0.0"
,
port
)
self
.
tstable_data
=
<
cprrt
.
PrrtTimestampTable
*>
malloc
(
sizeof
(
cprrt
.
Prrt
TimestampTable
))
self
.
tstable_redundancy
=
<
cprrt
.
PrrtTimestampTable
*>
malloc
(
sizeof
(
cprrt
.
Prrt
TimestampTable
))
self
.
tstable_data
=
<
cprrt
.
XlapTimestampTable
*>
malloc
(
sizeof
(
cprrt
.
Xlap
TimestampTable
))
self
.
tstable_redundancy
=
<
cprrt
.
XlapTimestampTable
*>
malloc
(
sizeof
(
cprrt
.
Xlap
TimestampTable
))
cprrt
.
Prrt
TimestampTableInstall
(
self
.
_c_socket
,
cprrt
.
ts_data_packet
,
self
.
tstable_data
)
cprrt
.
Prrt
TimestampTableInstall
(
self
.
_c_socket
,
cprrt
.
ts_redundancy_packet
,
self
.
tstable_redundancy
)
cprrt
.
Xlap
TimestampTableInstall
(
self
.
_c_socket
,
cprrt
.
ts_data_packet
,
self
.
tstable_data
)
cprrt
.
Xlap
TimestampTableInstall
(
self
.
_c_socket
,
cprrt
.
ts_redundancy_packet
,
self
.
tstable_redundancy
)
self
.
isSender
=
isSender
...
...
prrt/receiver.c
View file @
770f62df
...
...
@@ -36,12 +36,12 @@ int main(int argc, char* const argv[]) {
check
(
PrrtSocket_bind
(
sock
,
"0.0.0.0"
,
port
),
"bind failed"
);
check
(
sock
!=
NULL
,
"Could not create socket."
);
PrrtTimestampTable
*
tstable_data
=
malloc
(
sizeof
(
Prrt
TimestampTable
));
PrrtTimestampTable
*
tstable_redundancy
=
malloc
(
sizeof
(
Prrt
TimestampTable
));
XlapTimestampTable
*
tstable_data
=
malloc
(
sizeof
(
Xlap
TimestampTable
));
XlapTimestampTable
*
tstable_redundancy
=
malloc
(
sizeof
(
Xlap
TimestampTable
));
check
(
tstable_data
!=
NULL
,
"malloc failed"
);
check
(
tstable_redundancy
!=
NULL
,
"malloc failed"
);
Prrt
TimestampTableInstall
(
sock
,
ts_data_packet
,
tstable_data
);
Prrt
TimestampTableInstall
(
sock
,
ts_redundancy_packet
,
tstable_redundancy
);
Xlap
TimestampTableInstall
(
sock
,
ts_data_packet
,
tstable_data
);
Xlap
TimestampTableInstall
(
sock
,
ts_redundancy_packet
,
tstable_redundancy
);
uint32_t
i
=
0
;
while
(
i
<
rounds
&&
keepRunning
)
{
...
...
@@ -59,9 +59,9 @@ int main(int argc, char* const argv[]) {
usleep
(
1
);
}
Prrt
TimestampTableDumpHeader
(
out_desc
);
PrrtTimestampTableDump
(
out_desc
,
ts_data_packet
,
tstable_data
);
Prrt
TimestampTableDump
(
out_desc
,
ts_redundancy_packet
,
tstable_redundancy
);
Xlap
TimestampTableDumpHeader
(
out_desc
);
XlapTimestampTableDump
(
out_desc
,
ts_data_packet
,
tstable_data
);
Xlap
TimestampTableDump
(
out_desc
,
ts_redundancy_packet
,
tstable_redundancy
);
if
(
file_output
)
{
fclose
(
out_desc
);
...
...
prrt/sender.c
View file @
770f62df
...
...
@@ -36,12 +36,12 @@ int main(int argc, char *const argv[]) {
uint16_t
remote_port
=
port
;
PrrtSocket_connect
(
socket
,
remote_host
,
remote_port
);
PrrtTimestampTable
*
tstable_data
=
malloc
(
sizeof
(
Prrt
TimestampTable
));
PrrtTimestampTable
*
tstable_redundancy
=
malloc
(
sizeof
(
Prrt
TimestampTable
));
XlapTimestampTable
*
tstable_data
=
malloc
(
sizeof
(
Xlap
TimestampTable
));
XlapTimestampTable
*
tstable_redundancy
=
malloc
(
sizeof
(
Xlap
TimestampTable
));
check
(
tstable_data
!=
NULL
,
"malloc failed"
);
check
(
tstable_redundancy
!=
NULL
,
"malloc failed"
);
Prrt
TimestampTableInstall
(
socket
,
ts_data_packet
,
tstable_data
);
Prrt
TimestampTableInstall
(
socket
,
ts_redundancy_packet
,
tstable_redundancy
);
Xlap
TimestampTableInstall
(
socket
,
ts_data_packet
,
tstable_data
);
Xlap
TimestampTableInstall
(
socket
,
ts_redundancy_packet
,
tstable_redundancy
);
uint32_t
j
=
0
;
while
(
j
<
rounds
)
{
...
...
@@ -56,9 +56,9 @@ int main(int argc, char *const argv[]) {
usleep
(
1000
);
}
Prrt
TimestampTableDumpHeader
(
out_desc
);
PrrtTimestampTableDump
(
out_desc
,
ts_data_packet
,
tstable_data
);
Prrt
TimestampTableDump
(
out_desc
,
ts_redundancy_packet
,
tstable_redundancy
);
Xlap
TimestampTableDumpHeader
(
out_desc
);
XlapTimestampTableDump
(
out_desc
,
ts_data_packet
,
tstable_data
);
Xlap
TimestampTableDump
(
out_desc
,
ts_redundancy_packet
,
tstable_redundancy
);
if
(
file_output
)
{
fclose
(
out_desc
);
...
...
xlap
@
53cce0dd
Subproject commit 53cce0dd62db218131b3d8fd3e81a5855b2d9be4
Write
Preview
Markdown
is supported
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