Commit 4ae8c18c authored by Joanne Hugé's avatar Joanne Hugé

Add function to compute txtime in udp send packet function

parent 36134017
......@@ -39,6 +39,7 @@
#define SERVER_PORT_INT 50000
#define CLOCK_ID CLOCK_TAI
#define MESSAGE ((uint32_t)0x00FACADE)
#define NSEC_PER_SEC 1000000000
int send_udp_packet(const char *server_ip) {
int status;
......@@ -143,6 +144,17 @@ void init_udp_etf(int use_etf, int packet_priority, char *network_if) {
}
}
uint64_t get_txtime() {
struct timespec txtime_ts;
uint64_t txtime;
clock_gettime(CLOCK_TAI, &txtime_ts);
txtime = txtime_ts.tv_sec * NSEC_PER_SEC + txtime_ts.tv_nsec;
txtime += NSEC_PER_SEC;
return txtime;
}
/*
* Sends udp packets using the ETF qdisc
*/
......@@ -177,7 +189,7 @@ void send_udp_packet_etf(int use_etf, uint64_t txtime, const char *server_ip) {
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_TXTIME;
cmsg->cmsg_len = CMSG_LEN(sizeof(uint64_t));
*((uint64_t *)CMSG_DATA(cmsg)) = txtime;
*((uint64_t *)CMSG_DATA(cmsg)) = get_txtime();
msg.msg_controllen = cmsg->cmsg_len;
}
......
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