Commit 500fbe73 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Add cyclestamps for ChannelReceive and ChannelTransmit.

parent e1750612
Pipeline #1918 failed with stages
in 1 minute and 24 seconds
...@@ -202,8 +202,9 @@ static void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) { ...@@ -202,8 +202,9 @@ static void handle_redundancy_packet(PrrtSocket *socket, PrrtPacket *packet) {
return; return;
} }
void receive_from_socket(const PrrtSocket *socket_ptr, unsigned char *buffer_ptr, ssize_t *received_size, void receive_from_socket(PrrtSocket *socket_ptr, unsigned char buffer_ptr[65528], ssize_t *received_size,
struct sockaddr_in *remote_ptr, socklen_t *remote_len_ptr, struct timespec *packet_stamp_ptr) { struct sockaddr_in *remote_ptr, socklen_t *remote_len_ptr, struct timespec *packet_timestamp_ptr,
uint64_t *packet_cyclestamp_ptr) {
if (socket_ptr->isHardwareTimestamping) { if (socket_ptr->isHardwareTimestamping) {
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
struct msghdr msg; struct msghdr msg;
...@@ -229,7 +230,7 @@ void receive_from_socket(const PrrtSocket *socket_ptr, unsigned char *buffer_ptr ...@@ -229,7 +230,7 @@ void receive_from_socket(const PrrtSocket *socket_ptr, unsigned char *buffer_ptr
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
switch (cmsg->cmsg_type) { switch (cmsg->cmsg_type) {
case SO_TIMESTAMPNS: { case SO_TIMESTAMPNS: {
memcpy(packet_stamp_ptr, (struct timespec *) CMSG_DATA(cmsg), sizeof(struct timespec)); memcpy(packet_timestamp_ptr, (struct timespec *) CMSG_DATA(cmsg), sizeof(struct timespec));
break; break;
} }
default: default:
...@@ -240,8 +241,9 @@ void receive_from_socket(const PrrtSocket *socket_ptr, unsigned char *buffer_ptr ...@@ -240,8 +241,9 @@ void receive_from_socket(const PrrtSocket *socket_ptr, unsigned char *buffer_ptr
} else { } else {
*received_size = recvfrom(socket_ptr->dataSocketFd, buffer_ptr, MAX_PAYLOAD_LENGTH, 0, *received_size = recvfrom(socket_ptr->dataSocketFd, buffer_ptr, MAX_PAYLOAD_LENGTH, 0,
(struct sockaddr *) remote_ptr, remote_len_ptr); (struct sockaddr *) remote_ptr, remote_len_ptr);
clock_gettime(CLOCK_REALTIME, packet_stamp_ptr); clock_gettime(CLOCK_REALTIME, packet_timestamp_ptr);
} }
*packet_cyclestamp_ptr = __builtin_ia32_rdtsc();
} }
void *receive_data_loop(void *ptr) { void *receive_data_loop(void *ptr) {
...@@ -259,11 +261,12 @@ void *receive_data_loop(void *ptr) { ...@@ -259,11 +261,12 @@ void *receive_data_loop(void *ptr) {
XlapTimestampPlaceholderInitialize(&tsph2); XlapTimestampPlaceholderInitialize(&tsph2);
XlapTimestampPlaceholderInitialize(&tsph3); XlapTimestampPlaceholderInitialize(&tsph3);
struct timespec packet_recv_stamp; struct timespec packet_recv_timestamp;
receive_from_socket(sock_ptr, buffer, &n, &remote, &addrlen, &packet_recv_stamp); uint64_t packet_recv_cyclestamp = 0;
debug(DEBUG_HARDSTAMPING, "Packet TS:\t%ld.%09ld; Who? %s", (long) packet_recv_stamp.tv_sec, receive_from_socket(sock_ptr, buffer, &n, &remote, &addrlen, &packet_recv_timestamp, &packet_recv_cyclestamp);
packet_recv_stamp.tv_nsec, inet_ntoa(remote.sin_addr)); debug(DEBUG_HARDSTAMPING, "Packet TS:\t%ld.%09ld; Who? %s", (long) packet_recv_timestamp.tv_sec,
prrtTimestamp_t prrt_recv_timestamp = PrrtClock_TimespecToPrrtTimestamp(packet_recv_stamp); packet_recv_timestamp.tv_nsec, inet_ntoa(remote.sin_addr));
prrtTimestamp_t prrt_recv_timestamp = PrrtClock_TimespecToPrrtTimestamp(packet_recv_timestamp);
sock_ptr->lastReceivedTimestamp = prrt_recv_timestamp; sock_ptr->lastReceivedTimestamp = prrt_recv_timestamp;
XlapTimeStampClock(&tsph1, ts_any_packet, 0, LinkReceive); XlapTimeStampClock(&tsph1, ts_any_packet, 0, LinkReceive);
...@@ -291,7 +294,8 @@ void *receive_data_loop(void *ptr) { ...@@ -291,7 +294,8 @@ void *receive_data_loop(void *ptr) {
sentTimestamp = PrrtPacket_get_redundancy_timestamp(packet); sentTimestamp = PrrtPacket_get_redundancy_timestamp(packet);
} }
if (packetType == PACKET_TYPE_DATA || packetType == PACKET_TYPE_REDUNDANCY) { if (packetType == PACKET_TYPE_DATA || packetType == PACKET_TYPE_REDUNDANCY) {
XlapTimeStampValue(sock_ptr, kind, seqno, ChannelReceive, packet_recv_stamp); XlapCycleStampValue(sock_ptr, kind, seqno, ChannelReceive, packet_recv_cyclestamp);
XlapTimeStampValue(sock_ptr, kind, seqno, ChannelReceive, packet_recv_timestamp);
XlapTimestampPlaceholderUse(sock_ptr, kind, seqno, &tsph1); XlapTimestampPlaceholderUse(sock_ptr, kind, seqno, &tsph1);
XlapTimestampPlaceholderUse(sock_ptr, kind, seqno, &tsph2); XlapTimestampPlaceholderUse(sock_ptr, kind, seqno, &tsph2);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "../../util/common.h" #include "../../util/common.h"
#include "dataTransmitter.h" #include "dataTransmitter.h"
bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrtPacketLength_t length, struct timespec *packet_stamp_ptr) { bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrtPacketLength_t length, struct timespec *packet_timestamp, uint64_t* packet_clockstamp) {
if(sock_ptr->isHardwareTimestamping) { if(sock_ptr->isHardwareTimestamping) {
struct msghdr msg; struct msghdr msg;
struct iovec iov; struct iovec iov;
...@@ -28,6 +28,7 @@ bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrt ...@@ -28,6 +28,7 @@ bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrt
msg.msg_controllen = 0; msg.msg_controllen = 0;
sendmsg(sock_ptr->dataSocketFd, &msg, 0); sendmsg(sock_ptr->dataSocketFd, &msg, 0);
*packet_clockstamp = __builtin_ia32_rdtsc();
msg.msg_control = control; msg.msg_control = control;
iov.iov_len = MAX_PAYLOAD_LENGTH; iov.iov_len = MAX_PAYLOAD_LENGTH;
...@@ -46,8 +47,8 @@ bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrt ...@@ -46,8 +47,8 @@ bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrt
case SO_TIMESTAMPING: { case SO_TIMESTAMPING: {
// Note: The raw stamp [2] is used, because the others are 0. // Note: The raw stamp [2] is used, because the others are 0.
struct timespec *hardstamp = &(((struct timespec*) CMSG_DATA(cmsg))[2]); //TODO: This is ugly. struct timespec *hardstamp = &(((struct timespec*) CMSG_DATA(cmsg))[2]); //TODO: This is ugly.
memcpy(packet_stamp_ptr, hardstamp, sizeof(struct timespec)); memcpy(packet_timestamp, hardstamp, sizeof(struct timespec));
debug(DEBUG_HARDSTAMPING, "Hardware TS:\t%ld.%09ld", (long) packet_stamp_ptr->tv_sec, (long) packet_stamp_ptr->tv_nsec); debug(DEBUG_HARDSTAMPING, "Hardware TS:\t%ld.%09ld", (long) packet_timestamp->tv_sec, (long) packet_timestamp->tv_nsec);
break; break;
} }
default: default:
...@@ -59,8 +60,9 @@ bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrt ...@@ -59,8 +60,9 @@ bool send_to_socket(PrrtSocket* sock_ptr, PrrtReceiver *recv, uint8_t* buf, prrt
// TODO: [LATENCY] By knowing the time encoding etc. that happens upfront, one could make an adjustment here. // TODO: [LATENCY] By knowing the time encoding etc. that happens upfront, one could make an adjustment here.
check(sendto(sock_ptr->dataSocketFd, buf, length, 0, recv->ai->ai_addr, recv->ai->ai_addrlen) == check(sendto(sock_ptr->dataSocketFd, buf, length, 0, recv->ai->ai_addr, recv->ai->ai_addrlen) ==
length, "Sendto failed."); length, "Sendto failed.");
clock_gettime(CLOCK_REALTIME, packet_stamp_ptr); clock_gettime(CLOCK_REALTIME, packet_timestamp);
debug(DEBUG_HARDSTAMPING, "Software TS:\t%ld.%09ld", (long) packet_stamp_ptr->tv_sec, (long) packet_stamp_ptr->tv_nsec); *packet_clockstamp = __builtin_ia32_rdtsc();
debug(DEBUG_HARDSTAMPING, "Software TS:\t%ld.%09ld", (long) packet_timestamp->tv_sec, (long) packet_timestamp->tv_nsec);
} }
return true; return true;
...@@ -92,8 +94,10 @@ static bool send_packet(PrrtSocket *sock_ptr, PrrtPacket *packet) { ...@@ -92,8 +94,10 @@ static bool send_packet(PrrtSocket *sock_ptr, PrrtPacket *packet) {
} }
struct timespec timestamp; struct timespec timestamp;
send_to_socket(sock_ptr, sock_ptr->receiver, buf, length, &timestamp); uint64_t cyclestamp;
send_to_socket(sock_ptr, sock_ptr->receiver, buf, length, &timestamp, &cyclestamp);
XlapTimeStampValue(sock_ptr, ts_data_packet, packet->sequenceNumber, ChannelTransmit, timestamp); XlapTimeStampValue(sock_ptr, ts_data_packet, packet->sequenceNumber, ChannelTransmit, timestamp);
XlapCycleStampValue(sock_ptr, ts_data_packet, packet->sequenceNumber, ChannelTransmit, cyclestamp);
PrrtReceiver_add_outstanding_packet_state(sock_ptr->receiver, packet, PrrtClock_TimespecToPrrtTimestamp(timestamp)); PrrtReceiver_add_outstanding_packet_state(sock_ptr->receiver, packet, PrrtClock_TimespecToPrrtTimestamp(timestamp));
......
Subproject commit 1e793a4cd8e5fdb6461e5ddfcb9640f599e93bee Subproject commit 9a28c630e13f2153be49f04a004e9c96a7e01ba6
Supports Markdown
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