36 lines
862 B
C
36 lines
862 B
C
#pragma once
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <time.h>
|
|
#include <string.h>
|
|
#include "utils.h"
|
|
|
|
struct measure_params {
|
|
uint64_t max_measure;
|
|
uint64_t payload_size;
|
|
uint64_t interval;
|
|
uint8_t is_server;
|
|
};
|
|
|
|
struct measure_state {
|
|
struct measure_packet* mp_out;
|
|
struct measure_packet* mp_in;
|
|
ssize_t mp_nin;
|
|
int fd;
|
|
};
|
|
|
|
struct measure_packet {
|
|
uint64_t counter;
|
|
uint8_t flag;
|
|
struct timespec emit_time;
|
|
};
|
|
|
|
void measure_params_init(struct measure_params* mp);
|
|
void measure_state_init(struct measure_params* mp, struct measure_state* ms);
|
|
|
|
void measure_parse(struct measure_params* mp, struct measure_state* ms);
|
|
struct measure_packet* measure_generate(struct measure_params* mp, struct measure_state* ms);
|
|
|
|
void measure_next_tick(struct measure_params *mp, struct measure_state* ms, struct timespec *next);
|